#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
const int N = 2e3 + 5;
long long n,dp[N][N];
pair<long long,long long> rope[N];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for(int i=1;i<=n;i++) cin >> rope[i].fi >> rope[i].se;
sort(rope+1, rope+1+n);
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
dp[i][j] = max(dp[i-1][j], dp[i-1][min(n, j + rope[i].fi - 1)] + rope[i].se);
}
}
cout << max(dp[n][0], dp[n][1]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
424 KB |
Output is correct |
2 |
Correct |
3 ms |
760 KB |
Output is correct |
3 |
Correct |
3 ms |
760 KB |
Output is correct |
4 |
Correct |
2 ms |
888 KB |
Output is correct |
5 |
Correct |
3 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
760 KB |
Output is correct |
7 |
Correct |
3 ms |
888 KB |
Output is correct |
8 |
Correct |
15 ms |
12152 KB |
Output is correct |
9 |
Correct |
13 ms |
12152 KB |
Output is correct |
10 |
Correct |
15 ms |
12152 KB |
Output is correct |
11 |
Correct |
15 ms |
12152 KB |
Output is correct |
12 |
Correct |
36 ms |
31864 KB |
Output is correct |
13 |
Correct |
36 ms |
31864 KB |
Output is correct |
14 |
Correct |
37 ms |
31736 KB |
Output is correct |
15 |
Correct |
31 ms |
31736 KB |
Output is correct |
16 |
Correct |
35 ms |
31736 KB |
Output is correct |
17 |
Correct |
37 ms |
31708 KB |
Output is correct |
18 |
Correct |
35 ms |
31864 KB |
Output is correct |
19 |
Correct |
36 ms |
31796 KB |
Output is correct |
20 |
Correct |
36 ms |
31736 KB |
Output is correct |
21 |
Correct |
37 ms |
31736 KB |
Output is correct |
22 |
Correct |
40 ms |
31780 KB |
Output is correct |
23 |
Correct |
36 ms |
31800 KB |
Output is correct |
24 |
Correct |
31 ms |
31736 KB |
Output is correct |
25 |
Correct |
31 ms |
31736 KB |
Output is correct |
26 |
Correct |
31 ms |
31736 KB |
Output is correct |
27 |
Correct |
35 ms |
31796 KB |
Output is correct |
28 |
Correct |
33 ms |
31704 KB |
Output is correct |
29 |
Correct |
32 ms |
31736 KB |
Output is correct |
30 |
Correct |
34 ms |
31796 KB |
Output is correct |
31 |
Correct |
36 ms |
31736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
888 KB |
Output is correct |
2 |
Correct |
4 ms |
760 KB |
Output is correct |
3 |
Correct |
3 ms |
760 KB |
Output is correct |
4 |
Correct |
3 ms |
888 KB |
Output is correct |
5 |
Correct |
3 ms |
888 KB |
Output is correct |
6 |
Correct |
3 ms |
892 KB |
Output is correct |
7 |
Correct |
2 ms |
888 KB |
Output is correct |
8 |
Correct |
2 ms |
888 KB |
Output is correct |
9 |
Correct |
13 ms |
12180 KB |
Output is correct |
10 |
Correct |
12 ms |
12152 KB |
Output is correct |
11 |
Correct |
13 ms |
12152 KB |
Output is correct |
12 |
Correct |
13 ms |
12156 KB |
Output is correct |
13 |
Correct |
13 ms |
12152 KB |
Output is correct |
14 |
Correct |
12 ms |
12156 KB |
Output is correct |
15 |
Correct |
13 ms |
12220 KB |
Output is correct |
16 |
Correct |
12 ms |
12152 KB |
Output is correct |
17 |
Correct |
31 ms |
31744 KB |
Output is correct |
18 |
Correct |
31 ms |
31864 KB |
Output is correct |
19 |
Correct |
31 ms |
31844 KB |
Output is correct |
20 |
Correct |
34 ms |
31776 KB |
Output is correct |
21 |
Correct |
31 ms |
31736 KB |
Output is correct |
22 |
Correct |
31 ms |
31740 KB |
Output is correct |
23 |
Correct |
31 ms |
31744 KB |
Output is correct |
24 |
Correct |
31 ms |
31736 KB |
Output is correct |
25 |
Correct |
31 ms |
31736 KB |
Output is correct |
26 |
Correct |
31 ms |
31736 KB |
Output is correct |
27 |
Correct |
32 ms |
31736 KB |
Output is correct |
28 |
Correct |
31 ms |
31736 KB |
Output is correct |
29 |
Correct |
31 ms |
31736 KB |
Output is correct |
30 |
Correct |
31 ms |
31736 KB |
Output is correct |
31 |
Correct |
31 ms |
31740 KB |
Output is correct |
32 |
Correct |
31 ms |
31864 KB |
Output is correct |
33 |
Correct |
31 ms |
31736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
31720 KB |
Output is correct |
2 |
Correct |
31 ms |
31736 KB |
Output is correct |
3 |
Correct |
31 ms |
31736 KB |
Output is correct |
4 |
Correct |
31 ms |
31736 KB |
Output is correct |
5 |
Correct |
32 ms |
31736 KB |
Output is correct |
6 |
Correct |
31 ms |
31804 KB |
Output is correct |
7 |
Correct |
31 ms |
31736 KB |
Output is correct |
8 |
Correct |
31 ms |
31740 KB |
Output is correct |
9 |
Correct |
31 ms |
31736 KB |
Output is correct |
10 |
Correct |
31 ms |
31736 KB |
Output is correct |
11 |
Correct |
31 ms |
31736 KB |
Output is correct |
12 |
Correct |
32 ms |
31736 KB |
Output is correct |
13 |
Correct |
31 ms |
31736 KB |
Output is correct |
14 |
Correct |
31 ms |
31736 KB |
Output is correct |
15 |
Correct |
31 ms |
31736 KB |
Output is correct |
16 |
Correct |
31 ms |
31736 KB |
Output is correct |
17 |
Correct |
31 ms |
31736 KB |
Output is correct |
18 |
Correct |
32 ms |
31736 KB |
Output is correct |
19 |
Correct |
31 ms |
31736 KB |
Output is correct |
20 |
Correct |
31 ms |
31736 KB |
Output is correct |
21 |
Correct |
31 ms |
31736 KB |
Output is correct |
22 |
Correct |
31 ms |
31736 KB |
Output is correct |
23 |
Correct |
31 ms |
31736 KB |
Output is correct |
24 |
Correct |
31 ms |
31736 KB |
Output is correct |
25 |
Correct |
31 ms |
31736 KB |
Output is correct |