상담 완료하는데 걸리는 시간 T와 상담했을 때 받을 수 있는 금액 P가 주어졌을 때, 남은 N일 동안 받을 수 있는 최대 금액 구하기
#include <bits/stdc++.h>
using namespace std;
int n;
int t[20];
int p[20];
int d[20];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 1; i <= n; i++) cin >> t[i] >> p[i];
for(int i = n; i >= 1; i--){
if (i + t[i] - 1 <= n)
d[i] = max(d[i+1], p[i] + d[i + t[i]]);
else
d[i] = d[i+1];
}
cout << d[1];
}