//https://www.acmicpc.net/problem/14501 #include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int N; | |
int counsel[16][2]; | |
int dp[16]; | |
void input(); | |
void solve(int today, int earn); | |
int main(){ | |
| |
cin >> N; | |
input(); | |
solve(counsel[1][0], counsel[1][1]); | |
solve(1, 0); | |
cout << dp[N]; | |
return 0; | |
} | |
void input(){ | |
for(int i=1; i<=N; i++) | |
cin >> counsel[i][0] >> counsel[i][1]; | |
} | |
void solve(int today, int earn){ | |
if(today<=N){ | |
dp[today]=max(dp[today],earn); | |
} | |
if(today>=N){ | |
return; | |
} | |
solve(today+counsel[today+1][0], earn+counsel[today+1][1]); | |
solve(today+1, earn); | |
} |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
180406_14889_스타트와 링크 (0) | 2018.04.06 |
---|---|
180406_14502_연구소 (0) | 2018.04.06 |
180404_14500_테트로미노 (0) | 2018.04.04 |
180404_14499_주사위 굴리기 (0) | 2018.04.04 |
180403_2810_컵홀더 (0) | 2018.04.03 |