# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
200522 | 2020-02-07T04:54:54 Z | arnold518 | 스트랩 (JOI14_straps) | C++14 | 173 ms | 63780 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2000; const ll INF = 1e18; int N, A[MAXN+10], B[MAXN+10]; ll dp[MAXN+10][MAXN*2+10]; ll solve(int pos, int val) { if(pos==N+1) { if(val>=-1) return 0; else return -INF; } ll &ret=dp[pos][val+MAXN]; if(ret!=-1) return ret; ret=-INF; ret=max(ret, solve(pos+1, val)); ret=max(ret, solve(pos+1, min(N, val+A[pos]))+B[pos]); return ret; } int main() { int i, j; scanf("%d", &N); for(i=1; i<=N; i++) scanf("%d%d", &A[i], &B[i]), A[i]--; memset(dp, -1, sizeof(dp)); printf("%lld\n", solve(1, 0)); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 63352 KB | Output is correct |
2 | Correct | 41 ms | 63480 KB | Output is correct |
3 | Correct | 39 ms | 63352 KB | Output is correct |
4 | Correct | 40 ms | 63352 KB | Output is correct |
5 | Correct | 41 ms | 63480 KB | Output is correct |
6 | Correct | 42 ms | 63560 KB | Output is correct |
7 | Correct | 40 ms | 63352 KB | Output is correct |
8 | Correct | 40 ms | 63352 KB | Output is correct |
9 | Correct | 42 ms | 63352 KB | Output is correct |
10 | Correct | 41 ms | 63352 KB | Output is correct |
11 | Correct | 41 ms | 63480 KB | Output is correct |
12 | Correct | 40 ms | 63352 KB | Output is correct |
13 | Correct | 40 ms | 63352 KB | Output is correct |
14 | Correct | 41 ms | 63352 KB | Output is correct |
15 | Correct | 40 ms | 63352 KB | Output is correct |
16 | Correct | 41 ms | 63480 KB | Output is correct |
17 | Correct | 40 ms | 63352 KB | Output is correct |
18 | Correct | 41 ms | 63352 KB | Output is correct |
19 | Correct | 44 ms | 63352 KB | Output is correct |
20 | Correct | 40 ms | 63352 KB | Output is correct |
21 | Correct | 41 ms | 63352 KB | Output is correct |
22 | Correct | 42 ms | 63448 KB | Output is correct |
23 | Correct | 41 ms | 63480 KB | Output is correct |
24 | Correct | 39 ms | 63352 KB | Output is correct |
25 | Correct | 41 ms | 63352 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 63352 KB | Output is correct |
2 | Correct | 40 ms | 63352 KB | Output is correct |
3 | Correct | 40 ms | 63352 KB | Output is correct |
4 | Correct | 41 ms | 63480 KB | Output is correct |
5 | Correct | 39 ms | 63352 KB | Output is correct |
6 | Correct | 41 ms | 63352 KB | Output is correct |
7 | Correct | 42 ms | 63352 KB | Output is correct |
8 | Correct | 53 ms | 63480 KB | Output is correct |
9 | Correct | 51 ms | 63480 KB | Output is correct |
10 | Correct | 50 ms | 63480 KB | Output is correct |
11 | Correct | 51 ms | 63480 KB | Output is correct |
12 | Correct | 87 ms | 63480 KB | Output is correct |
13 | Correct | 89 ms | 63568 KB | Output is correct |
14 | Correct | 98 ms | 63480 KB | Output is correct |
15 | Correct | 97 ms | 63608 KB | Output is correct |
16 | Correct | 92 ms | 63480 KB | Output is correct |
17 | Correct | 95 ms | 63480 KB | Output is correct |
18 | Correct | 93 ms | 63608 KB | Output is correct |
19 | Correct | 108 ms | 63480 KB | Output is correct |
20 | Correct | 102 ms | 63480 KB | Output is correct |
21 | Correct | 116 ms | 63480 KB | Output is correct |
22 | Correct | 96 ms | 63480 KB | Output is correct |
23 | Correct | 143 ms | 63476 KB | Output is correct |
24 | Correct | 104 ms | 63484 KB | Output is correct |
25 | Correct | 138 ms | 63480 KB | Output is correct |
26 | Correct | 118 ms | 63584 KB | Output is correct |
27 | Correct | 136 ms | 63484 KB | Output is correct |
28 | Correct | 87 ms | 63480 KB | Output is correct |
29 | Correct | 122 ms | 63584 KB | Output is correct |
30 | Correct | 120 ms | 63608 KB | Output is correct |
31 | Correct | 113 ms | 63524 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 41 ms | 63480 KB | Output is correct |
2 | Correct | 50 ms | 63480 KB | Output is correct |
3 | Correct | 40 ms | 63480 KB | Output is correct |
4 | Correct | 41 ms | 63480 KB | Output is correct |
5 | Correct | 40 ms | 63480 KB | Output is correct |
6 | Correct | 40 ms | 63352 KB | Output is correct |
7 | Correct | 41 ms | 63352 KB | Output is correct |
8 | Correct | 41 ms | 63352 KB | Output is correct |
9 | Correct | 53 ms | 63480 KB | Output is correct |
10 | Correct | 50 ms | 63480 KB | Output is correct |
11 | Correct | 51 ms | 63480 KB | Output is correct |
12 | Correct | 50 ms | 63480 KB | Output is correct |
13 | Correct | 52 ms | 63480 KB | Output is correct |
14 | Correct | 51 ms | 63480 KB | Output is correct |
15 | Correct | 60 ms | 63480 KB | Output is correct |
16 | Correct | 52 ms | 63608 KB | Output is correct |
17 | Correct | 99 ms | 63608 KB | Output is correct |
18 | Correct | 90 ms | 63480 KB | Output is correct |
19 | Correct | 97 ms | 63480 KB | Output is correct |
20 | Correct | 98 ms | 63608 KB | Output is correct |
21 | Correct | 100 ms | 63484 KB | Output is correct |
22 | Correct | 101 ms | 63480 KB | Output is correct |
23 | Correct | 92 ms | 63480 KB | Output is correct |
24 | Correct | 98 ms | 63608 KB | Output is correct |
25 | Correct | 90 ms | 63608 KB | Output is correct |
26 | Correct | 90 ms | 63480 KB | Output is correct |
27 | Correct | 87 ms | 63480 KB | Output is correct |
28 | Correct | 89 ms | 63608 KB | Output is correct |
29 | Correct | 100 ms | 63480 KB | Output is correct |
30 | Correct | 92 ms | 63780 KB | Output is correct |
31 | Correct | 91 ms | 63580 KB | Output is correct |
32 | Correct | 86 ms | 63480 KB | Output is correct |
33 | Correct | 54 ms | 63480 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 98 ms | 63608 KB | Output is correct |
2 | Correct | 100 ms | 63480 KB | Output is correct |
3 | Correct | 100 ms | 63608 KB | Output is correct |
4 | Correct | 99 ms | 63480 KB | Output is correct |
5 | Correct | 126 ms | 63480 KB | Output is correct |
6 | Correct | 132 ms | 63608 KB | Output is correct |
7 | Correct | 127 ms | 63700 KB | Output is correct |
8 | Correct | 113 ms | 63480 KB | Output is correct |
9 | Correct | 131 ms | 63480 KB | Output is correct |
10 | Correct | 138 ms | 63480 KB | Output is correct |
11 | Correct | 139 ms | 63480 KB | Output is correct |
12 | Correct | 139 ms | 63656 KB | Output is correct |
13 | Correct | 131 ms | 63480 KB | Output is correct |
14 | Correct | 130 ms | 63480 KB | Output is correct |
15 | Correct | 142 ms | 63560 KB | Output is correct |
16 | Correct | 146 ms | 63612 KB | Output is correct |
17 | Correct | 173 ms | 63592 KB | Output is correct |
18 | Correct | 166 ms | 63480 KB | Output is correct |
19 | Correct | 112 ms | 63484 KB | Output is correct |
20 | Correct | 112 ms | 63612 KB | Output is correct |
21 | Correct | 115 ms | 63612 KB | Output is correct |
22 | Correct | 110 ms | 63608 KB | Output is correct |
23 | Correct | 114 ms | 63480 KB | Output is correct |
24 | Correct | 123 ms | 63580 KB | Output is correct |
25 | Correct | 82 ms | 63608 KB | Output is correct |