# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
157217 |
2019-10-10T07:01:11 Z |
manh9203 |
스트랩 (JOI14_straps) |
C++17 |
|
39 ms |
31924 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,int> 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(n, 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 |
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 |
248 KB |
Output is correct |
10 |
Correct |
2 ms |
404 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 |
2 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 |
760 KB |
Output is correct |
8 |
Correct |
14 ms |
12152 KB |
Output is correct |
9 |
Correct |
14 ms |
12152 KB |
Output is correct |
10 |
Correct |
15 ms |
12128 KB |
Output is correct |
11 |
Correct |
16 ms |
12152 KB |
Output is correct |
12 |
Correct |
39 ms |
31708 KB |
Output is correct |
13 |
Correct |
33 ms |
31776 KB |
Output is correct |
14 |
Correct |
34 ms |
31864 KB |
Output is correct |
15 |
Correct |
33 ms |
31736 KB |
Output is correct |
16 |
Correct |
33 ms |
31736 KB |
Output is correct |
17 |
Correct |
34 ms |
31736 KB |
Output is correct |
18 |
Correct |
34 ms |
31864 KB |
Output is correct |
19 |
Correct |
34 ms |
31736 KB |
Output is correct |
20 |
Correct |
34 ms |
31736 KB |
Output is correct |
21 |
Correct |
33 ms |
31752 KB |
Output is correct |
22 |
Correct |
33 ms |
31740 KB |
Output is correct |
23 |
Correct |
34 ms |
31736 KB |
Output is correct |
24 |
Correct |
33 ms |
31736 KB |
Output is correct |
25 |
Incorrect |
34 ms |
31876 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
760 KB |
Output is correct |
2 |
Correct |
2 ms |
860 KB |
Output is correct |
3 |
Correct |
3 ms |
932 KB |
Output is correct |
4 |
Correct |
3 ms |
888 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 |
14 ms |
12280 KB |
Output is correct |
12 |
Correct |
13 ms |
12280 KB |
Output is correct |
13 |
Correct |
13 ms |
12152 KB |
Output is correct |
14 |
Correct |
13 ms |
12284 KB |
Output is correct |
15 |
Correct |
13 ms |
12152 KB |
Output is correct |
16 |
Correct |
13 ms |
12152 KB |
Output is correct |
17 |
Correct |
34 ms |
31736 KB |
Output is correct |
18 |
Correct |
34 ms |
31736 KB |
Output is correct |
19 |
Correct |
34 ms |
31736 KB |
Output is correct |
20 |
Correct |
33 ms |
31736 KB |
Output is correct |
21 |
Correct |
33 ms |
31896 KB |
Output is correct |
22 |
Correct |
33 ms |
31736 KB |
Output is correct |
23 |
Correct |
33 ms |
31736 KB |
Output is correct |
24 |
Correct |
33 ms |
31808 KB |
Output is correct |
25 |
Correct |
33 ms |
31736 KB |
Output is correct |
26 |
Correct |
33 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 |
33 ms |
31736 KB |
Output is correct |
30 |
Correct |
33 ms |
31772 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 |
31740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
31736 KB |
Output is correct |
2 |
Correct |
33 ms |
31744 KB |
Output is correct |
3 |
Correct |
33 ms |
31924 KB |
Output is correct |
4 |
Correct |
33 ms |
31736 KB |
Output is correct |
5 |
Correct |
33 ms |
31736 KB |
Output is correct |
6 |
Incorrect |
33 ms |
31736 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |