14501번 풀이 (1) 썸네일형 리스트형 백준 14501번 퇴사 C/C++ 풀이 https://www.acmicpc.net/problem/14501 14501번: 퇴사 첫째 줄에 백준이가 얻을 수 있는 최대 이익을 출력한다. www.acmicpc.net 동적계획법으로 풀었다. 배낭 알고리즘을 응용해서 풀었다. #include #include using namespace std; FILE* in = fopen("input.txt", "r"); #define MAX 15 int n; int time[MAX]; int pay[MAX]; int cache[MAX+1][MAX * 1000]; int dp(int idx, int cost) { //메모이제이션 if (cache[idx][cost] != 0) return cache[idx][cost]; if (idx == n) return cos.. 이전 1 다음