# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
157220 |
2019-10-10T07:05:52 Z |
manh9203 |
스트랩 (JOI14_straps) |
C++17 |
|
38 ms |
31864 KB |
#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;
for(int i=0;i<=n;i++){
for(int j=1;j<=n;j++){
dp[i][j] = -1e18;
}
}
sort(rope+1, rope+1+n);
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
dp[i][j] = max(dp[i-1][min((long long)i-1, j + rope[i].fi - 1)], dp[i-1][j-1]) + rope[i].se;
dp[i][j] = max(dp[i][j], dp[i-1][j]);
}
}
cout << max(dp[n][0], dp[n][1]);
}
# |
Verdict |
Execution time |
Memory |
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 |
380 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
424 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
1 ms |
888 KB |
Output is correct |
3 |
Correct |
2 ms |
760 KB |
Output is correct |
4 |
Correct |
2 ms |
756 KB |
Output is correct |
5 |
Correct |
2 ms |
888 KB |
Output is correct |
6 |
Correct |
2 ms |
760 KB |
Output is correct |
7 |
Correct |
2 ms |
888 KB |
Output is correct |
8 |
Correct |
12 ms |
12152 KB |
Output is correct |
9 |
Correct |
13 ms |
12152 KB |
Output is correct |
10 |
Correct |
13 ms |
12152 KB |
Output is correct |
11 |
Correct |
13 ms |
12176 KB |
Output is correct |
12 |
Correct |
33 ms |
31708 KB |
Output is correct |
13 |
Correct |
33 ms |
31736 KB |
Output is correct |
14 |
Correct |
34 ms |
31736 KB |
Output is correct |
15 |
Correct |
34 ms |
31812 KB |
Output is correct |
16 |
Correct |
34 ms |
31736 KB |
Output is correct |
17 |
Correct |
33 ms |
31808 KB |
Output is correct |
18 |
Correct |
34 ms |
31736 KB |
Output is correct |
19 |
Correct |
34 ms |
31736 KB |
Output is correct |
20 |
Correct |
37 ms |
31736 KB |
Output is correct |
21 |
Correct |
33 ms |
31736 KB |
Output is correct |
22 |
Correct |
34 ms |
31736 KB |
Output is correct |
23 |
Correct |
33 ms |
31736 KB |
Output is correct |
24 |
Correct |
33 ms |
31736 KB |
Output is correct |
25 |
Correct |
33 ms |
31736 KB |
Output is correct |
26 |
Correct |
33 ms |
31864 KB |
Output is correct |
27 |
Correct |
33 ms |
31736 KB |
Output is correct |
28 |
Correct |
33 ms |
31736 KB |
Output is correct |
29 |
Correct |
33 ms |
31736 KB |
Output is correct |
30 |
Correct |
32 ms |
31736 KB |
Output is correct |
31 |
Correct |
33 ms |
31736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
760 KB |
Output is correct |
2 |
Correct |
2 ms |
760 KB |
Output is correct |
3 |
Correct |
3 ms |
860 KB |
Output is correct |
4 |
Correct |
2 ms |
760 KB |
Output is correct |
5 |
Correct |
2 ms |
760 KB |
Output is correct |
6 |
Correct |
2 ms |
760 KB |
Output is correct |
7 |
Correct |
2 ms |
760 KB |
Output is correct |
8 |
Correct |
2 ms |
760 KB |
Output is correct |
9 |
Correct |
13 ms |
12152 KB |
Output is correct |
10 |
Correct |
13 ms |
12152 KB |
Output is correct |
11 |
Correct |
13 ms |
12152 KB |
Output is correct |
12 |
Correct |
15 ms |
12252 KB |
Output is correct |
13 |
Correct |
13 ms |
12228 KB |
Output is correct |
14 |
Correct |
13 ms |
12152 KB |
Output is correct |
15 |
Correct |
13 ms |
12152 KB |
Output is correct |
16 |
Correct |
13 ms |
12152 KB |
Output is correct |
17 |
Correct |
33 ms |
31736 KB |
Output is correct |
18 |
Correct |
33 ms |
31864 KB |
Output is correct |
19 |
Correct |
33 ms |
31736 KB |
Output is correct |
20 |
Correct |
33 ms |
31736 KB |
Output is correct |
21 |
Correct |
33 ms |
31736 KB |
Output is correct |
22 |
Correct |
33 ms |
31736 KB |
Output is correct |
23 |
Correct |
33 ms |
31784 KB |
Output is correct |
24 |
Correct |
33 ms |
31736 KB |
Output is correct |
25 |
Correct |
34 ms |
31736 KB |
Output is correct |
26 |
Correct |
34 ms |
31736 KB |
Output is correct |
27 |
Correct |
33 ms |
31736 KB |
Output is correct |
28 |
Correct |
33 ms |
31736 KB |
Output is correct |
29 |
Correct |
34 ms |
31736 KB |
Output is correct |
30 |
Correct |
33 ms |
31736 KB |
Output is correct |
31 |
Correct |
33 ms |
31736 KB |
Output is correct |
32 |
Correct |
33 ms |
31736 KB |
Output is correct |
33 |
Correct |
33 ms |
31736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
31824 KB |
Output is correct |
2 |
Correct |
33 ms |
31736 KB |
Output is correct |
3 |
Correct |
34 ms |
31864 KB |
Output is correct |
4 |
Correct |
33 ms |
31736 KB |
Output is correct |
5 |
Correct |
33 ms |
31736 KB |
Output is correct |
6 |
Incorrect |
34 ms |
31736 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |