# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25554 | 2017-06-23T04:43:25 Z | zigui | 스트랩 (JOI14_straps) | C++14 | 26 ms | 32540 KB |
#include<stdio.h> #include<vector> #include<algorithm> #include<set> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MX = 2005; ll T[MX][MX]; pii D[MX]; int N; int main() { scanf("%d", &N); for(int i = 1; i <= N; i++) scanf("%d%d", &D[i].first, &D[i].second), D[i].first--; sort(D+1, D+N+1); reverse(D+1, D+N+1); for(int i = 2; i <= N; i++) T[0][i] = -2e9; for(int i = 1; i <= N; i++){ for(int j = 0; j <= N; j++) T[i][j] = T[i-1][j]; for(int j = 0; j <= N; j++){ int w = j + D[i].first; if( w < 0 ) continue; if( w > N ) w = N; T[i][w] = max(T[i][w], T[i-1][j] + D[i].second); } } ll mx = 0; for(int i = 0; i <= N; i++) mx = max(mx, T[N][i]); printf("%lld\n", mx); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 32540 KB | Output is correct |
2 | Correct | 0 ms | 32540 KB | Output is correct |
3 | Correct | 0 ms | 32540 KB | Output is correct |
4 | Correct | 0 ms | 32540 KB | Output is correct |
5 | Correct | 0 ms | 32540 KB | Output is correct |
6 | Correct | 0 ms | 32540 KB | Output is correct |
7 | Correct | 0 ms | 32540 KB | Output is correct |
8 | Correct | 0 ms | 32540 KB | Output is correct |
9 | Correct | 0 ms | 32540 KB | Output is correct |
10 | Correct | 0 ms | 32540 KB | Output is correct |
11 | Correct | 0 ms | 32540 KB | Output is correct |
12 | Correct | 0 ms | 32540 KB | Output is correct |
13 | Correct | 0 ms | 32540 KB | Output is correct |
14 | Correct | 0 ms | 32540 KB | Output is correct |
15 | Correct | 0 ms | 32540 KB | Output is correct |
16 | Correct | 0 ms | 32540 KB | Output is correct |
17 | Correct | 0 ms | 32540 KB | Output is correct |
18 | Correct | 0 ms | 32540 KB | Output is correct |
19 | Correct | 0 ms | 32540 KB | Output is correct |
20 | Correct | 0 ms | 32540 KB | Output is correct |
21 | Correct | 0 ms | 32540 KB | Output is correct |
22 | Correct | 0 ms | 32540 KB | Output is correct |
23 | Correct | 0 ms | 32540 KB | Output is correct |
24 | Correct | 0 ms | 32540 KB | Output is correct |
25 | Correct | 0 ms | 32540 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 32540 KB | Output is correct |
2 | Correct | 0 ms | 32540 KB | Output is correct |
3 | Correct | 0 ms | 32540 KB | Output is correct |
4 | Correct | 0 ms | 32540 KB | Output is correct |
5 | Correct | 0 ms | 32540 KB | Output is correct |
6 | Correct | 0 ms | 32540 KB | Output is correct |
7 | Correct | 0 ms | 32540 KB | Output is correct |
8 | Correct | 3 ms | 32540 KB | Output is correct |
9 | Correct | 3 ms | 32540 KB | Output is correct |
10 | Correct | 6 ms | 32540 KB | Output is correct |
11 | Correct | 0 ms | 32540 KB | Output is correct |
12 | Correct | 13 ms | 32540 KB | Output is correct |
13 | Correct | 6 ms | 32540 KB | Output is correct |
14 | Correct | 6 ms | 32540 KB | Output is correct |
15 | Correct | 6 ms | 32540 KB | Output is correct |
16 | Correct | 19 ms | 32540 KB | Output is correct |
17 | Correct | 9 ms | 32540 KB | Output is correct |
18 | Correct | 13 ms | 32540 KB | Output is correct |
19 | Correct | 6 ms | 32540 KB | Output is correct |
20 | Correct | 6 ms | 32540 KB | Output is correct |
21 | Correct | 13 ms | 32540 KB | Output is correct |
22 | Correct | 16 ms | 32540 KB | Output is correct |
23 | Correct | 9 ms | 32540 KB | Output is correct |
24 | Correct | 13 ms | 32540 KB | Output is correct |
25 | Correct | 9 ms | 32540 KB | Output is correct |
26 | Correct | 13 ms | 32540 KB | Output is correct |
27 | Correct | 23 ms | 32540 KB | Output is correct |
28 | Correct | 9 ms | 32540 KB | Output is correct |
29 | Correct | 16 ms | 32540 KB | Output is correct |
30 | Correct | 13 ms | 32540 KB | Output is correct |
31 | Correct | 13 ms | 32540 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 32540 KB | Output is correct |
2 | Correct | 0 ms | 32540 KB | Output is correct |
3 | Correct | 0 ms | 32540 KB | Output is correct |
4 | Correct | 0 ms | 32540 KB | Output is correct |
5 | Correct | 0 ms | 32540 KB | Output is correct |
6 | Correct | 0 ms | 32540 KB | Output is correct |
7 | Correct | 0 ms | 32540 KB | Output is correct |
8 | Correct | 0 ms | 32540 KB | Output is correct |
9 | Correct | 0 ms | 32540 KB | Output is correct |
10 | Correct | 0 ms | 32540 KB | Output is correct |
11 | Correct | 6 ms | 32540 KB | Output is correct |
12 | Correct | 0 ms | 32540 KB | Output is correct |
13 | Correct | 3 ms | 32540 KB | Output is correct |
14 | Correct | 3 ms | 32540 KB | Output is correct |
15 | Correct | 3 ms | 32540 KB | Output is correct |
16 | Correct | 6 ms | 32540 KB | Output is correct |
17 | Correct | 13 ms | 32540 KB | Output is correct |
18 | Correct | 13 ms | 32540 KB | Output is correct |
19 | Correct | 9 ms | 32540 KB | Output is correct |
20 | Correct | 16 ms | 32540 KB | Output is correct |
21 | Correct | 16 ms | 32540 KB | Output is correct |
22 | Correct | 13 ms | 32540 KB | Output is correct |
23 | Correct | 9 ms | 32540 KB | Output is correct |
24 | Correct | 3 ms | 32540 KB | Output is correct |
25 | Correct | 23 ms | 32540 KB | Output is correct |
26 | Correct | 26 ms | 32540 KB | Output is correct |
27 | Correct | 23 ms | 32540 KB | Output is correct |
28 | Correct | 19 ms | 32540 KB | Output is correct |
29 | Correct | 23 ms | 32540 KB | Output is correct |
30 | Correct | 9 ms | 32540 KB | Output is correct |
31 | Correct | 6 ms | 32540 KB | Output is correct |
32 | Correct | 9 ms | 32540 KB | Output is correct |
33 | Correct | 9 ms | 32540 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 32540 KB | Output is correct |
2 | Correct | 6 ms | 32540 KB | Output is correct |
3 | Correct | 9 ms | 32540 KB | Output is correct |
4 | Correct | 9 ms | 32540 KB | Output is correct |
5 | Correct | 13 ms | 32540 KB | Output is correct |
6 | Correct | 3 ms | 32540 KB | Output is correct |
7 | Correct | 19 ms | 32540 KB | Output is correct |
8 | Correct | 16 ms | 32540 KB | Output is correct |
9 | Correct | 3 ms | 32540 KB | Output is correct |
10 | Correct | 6 ms | 32540 KB | Output is correct |
11 | Correct | 9 ms | 32540 KB | Output is correct |
12 | Correct | 9 ms | 32540 KB | Output is correct |
13 | Correct | 9 ms | 32540 KB | Output is correct |
14 | Correct | 6 ms | 32540 KB | Output is correct |
15 | Correct | 19 ms | 32540 KB | Output is correct |
16 | Correct | 13 ms | 32540 KB | Output is correct |
17 | Correct | 9 ms | 32540 KB | Output is correct |
18 | Correct | 16 ms | 32540 KB | Output is correct |
19 | Correct | 6 ms | 32540 KB | Output is correct |
20 | Correct | 16 ms | 32540 KB | Output is correct |
21 | Correct | 9 ms | 32540 KB | Output is correct |
22 | Correct | 16 ms | 32540 KB | Output is correct |
23 | Correct | 23 ms | 32540 KB | Output is correct |
24 | Correct | 16 ms | 32540 KB | Output is correct |
25 | Correct | 9 ms | 32540 KB | Output is correct |