-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
27 lines (23 loc) · 667 Bytes
/
Copy pathmain.cpp
File metadata and controls
27 lines (23 loc) · 667 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <algorithm>
using namespace std;
int N, ans;
pair<int, int> days[16];
void dfs(int current, pair<int, int> node, int current_sum) {
if(current + node.first > N+1) return;
current_sum += node.second;
if(ans < current_sum) ans = current_sum;
for(int next = current + node.first; next <= N; next++) {
dfs(next, days[next], current_sum);
}
current_sum -= node.second;
}
int main() {
cin >> N;
for(int i=1; i<=N; i++)
cin >> days[i].first >> days[i].second;
for(int start=1; start<=N; start++)
dfs(start, days[start], 0);
cout << ans << '\n';
return 0;
}