# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
32111 | 2017-09-26T06:06:05 Z | TAMREF | 스트랩 (JOI14_straps) | C++11 | 33 ms | 33436 KB |
#include <bits/stdc++.h> using namespace std; using ii = pair<int,int>; const int ilb = INT_MIN; int dp[2005][2005], vis[2005][2005]; ii f[2005]; int n; void input(){ scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d %d",&f[i].first,&f[i].second); sort(f,f+n,greater<ii>()); for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) dp[i][j]=ilb; dp[0][1]=0; } void work(){ for(int i=0;i<n;i++){ for(int j=0,k;j<=n;j++){ dp[i+1][j]=max(dp[i+1][j],dp[i][j]); k=min(n,j+f[i].first-1); if(j && dp[i][j]!=ilb) dp[i+1][k]=max(dp[i+1][k],dp[i][j]+f[i].second); } } } int main(){ input(); work(); printf("%d\n",*max_element(dp[n],dp[n]+n+1)); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 33436 KB | Output is correct |
2 | Correct | 0 ms | 33436 KB | Output is correct |
3 | Correct | 0 ms | 33436 KB | Output is correct |
4 | Correct | 0 ms | 33436 KB | Output is correct |
5 | Correct | 0 ms | 33436 KB | Output is correct |
6 | Correct | 0 ms | 33436 KB | Output is correct |
7 | Correct | 0 ms | 33436 KB | Output is correct |
8 | Correct | 0 ms | 33436 KB | Output is correct |
9 | Correct | 0 ms | 33436 KB | Output is correct |
10 | Correct | 0 ms | 33436 KB | Output is correct |
11 | Correct | 0 ms | 33436 KB | Output is correct |
12 | Correct | 0 ms | 33436 KB | Output is correct |
13 | Correct | 0 ms | 33436 KB | Output is correct |
14 | Correct | 0 ms | 33436 KB | Output is correct |
15 | Correct | 0 ms | 33436 KB | Output is correct |
16 | Correct | 0 ms | 33436 KB | Output is correct |
17 | Correct | 0 ms | 33436 KB | Output is correct |
18 | Correct | 0 ms | 33436 KB | Output is correct |
19 | Correct | 0 ms | 33436 KB | Output is correct |
20 | Correct | 0 ms | 33436 KB | Output is correct |
21 | Correct | 0 ms | 33436 KB | Output is correct |
22 | Correct | 0 ms | 33436 KB | Output is correct |
23 | Correct | 0 ms | 33436 KB | Output is correct |
24 | Correct | 0 ms | 33436 KB | Output is correct |
25 | Correct | 0 ms | 33436 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 33436 KB | Output is correct |
2 | Correct | 0 ms | 33436 KB | Output is correct |
3 | Correct | 0 ms | 33436 KB | Output is correct |
4 | Correct | 0 ms | 33436 KB | Output is correct |
5 | Correct | 0 ms | 33436 KB | Output is correct |
6 | Correct | 0 ms | 33436 KB | Output is correct |
7 | Correct | 0 ms | 33436 KB | Output is correct |
8 | Correct | 0 ms | 33436 KB | Output is correct |
9 | Correct | 3 ms | 33436 KB | Output is correct |
10 | Correct | 3 ms | 33436 KB | Output is correct |
11 | Correct | 6 ms | 33436 KB | Output is correct |
12 | Correct | 13 ms | 33436 KB | Output is correct |
13 | Correct | 9 ms | 33436 KB | Output is correct |
14 | Correct | 16 ms | 33436 KB | Output is correct |
15 | Correct | 13 ms | 33436 KB | Output is correct |
16 | Correct | 9 ms | 33436 KB | Output is correct |
17 | Correct | 16 ms | 33436 KB | Output is correct |
18 | Correct | 16 ms | 33436 KB | Output is correct |
19 | Correct | 9 ms | 33436 KB | Output is correct |
20 | Correct | 19 ms | 33436 KB | Output is correct |
21 | Correct | 23 ms | 33436 KB | Output is correct |
22 | Correct | 13 ms | 33436 KB | Output is correct |
23 | Correct | 16 ms | 33436 KB | Output is correct |
24 | Correct | 13 ms | 33436 KB | Output is correct |
25 | Correct | 26 ms | 33436 KB | Output is correct |
26 | Correct | 9 ms | 33436 KB | Output is correct |
27 | Correct | 16 ms | 33436 KB | Output is correct |
28 | Correct | 13 ms | 33436 KB | Output is correct |
29 | Correct | 19 ms | 33436 KB | Output is correct |
30 | Correct | 19 ms | 33436 KB | Output is correct |
31 | Correct | 16 ms | 33436 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 33436 KB | Output is correct |
2 | Correct | 0 ms | 33436 KB | Output is correct |
3 | Correct | 0 ms | 33436 KB | Output is correct |
4 | Correct | 0 ms | 33436 KB | Output is correct |
5 | Correct | 0 ms | 33436 KB | Output is correct |
6 | Correct | 0 ms | 33436 KB | Output is correct |
7 | Correct | 0 ms | 33436 KB | Output is correct |
8 | Correct | 0 ms | 33436 KB | Output is correct |
9 | Correct | 6 ms | 33436 KB | Output is correct |
10 | Correct | 6 ms | 33436 KB | Output is correct |
11 | Correct | 0 ms | 33436 KB | Output is correct |
12 | Correct | 3 ms | 33436 KB | Output is correct |
13 | Correct | 3 ms | 33436 KB | Output is correct |
14 | Correct | 3 ms | 33436 KB | Output is correct |
15 | Correct | 6 ms | 33436 KB | Output is correct |
16 | Correct | 6 ms | 33436 KB | Output is correct |
17 | Correct | 13 ms | 33436 KB | Output is correct |
18 | Correct | 6 ms | 33436 KB | Output is correct |
19 | Correct | 16 ms | 33436 KB | Output is correct |
20 | Correct | 13 ms | 33436 KB | Output is correct |
21 | Correct | 9 ms | 33436 KB | Output is correct |
22 | Correct | 13 ms | 33436 KB | Output is correct |
23 | Correct | 13 ms | 33436 KB | Output is correct |
24 | Correct | 13 ms | 33436 KB | Output is correct |
25 | Correct | 16 ms | 33436 KB | Output is correct |
26 | Correct | 16 ms | 33436 KB | Output is correct |
27 | Correct | 6 ms | 33436 KB | Output is correct |
28 | Correct | 13 ms | 33436 KB | Output is correct |
29 | Correct | 13 ms | 33436 KB | Output is correct |
30 | Correct | 13 ms | 33436 KB | Output is correct |
31 | Correct | 9 ms | 33436 KB | Output is correct |
32 | Correct | 9 ms | 33436 KB | Output is correct |
33 | Correct | 13 ms | 33436 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 33436 KB | Output is correct |
2 | Correct | 9 ms | 33436 KB | Output is correct |
3 | Correct | 13 ms | 33436 KB | Output is correct |
4 | Correct | 9 ms | 33436 KB | Output is correct |
5 | Correct | 16 ms | 33436 KB | Output is correct |
6 | Correct | 13 ms | 33436 KB | Output is correct |
7 | Correct | 13 ms | 33436 KB | Output is correct |
8 | Correct | 13 ms | 33436 KB | Output is correct |
9 | Correct | 16 ms | 33436 KB | Output is correct |
10 | Correct | 33 ms | 33436 KB | Output is correct |
11 | Correct | 13 ms | 33436 KB | Output is correct |
12 | Correct | 16 ms | 33436 KB | Output is correct |
13 | Correct | 16 ms | 33436 KB | Output is correct |
14 | Correct | 13 ms | 33436 KB | Output is correct |
15 | Correct | 16 ms | 33436 KB | Output is correct |
16 | Correct | 23 ms | 33436 KB | Output is correct |
17 | Correct | 13 ms | 33436 KB | Output is correct |
18 | Correct | 19 ms | 33436 KB | Output is correct |
19 | Correct | 16 ms | 33436 KB | Output is correct |
20 | Correct | 13 ms | 33436 KB | Output is correct |
21 | Correct | 19 ms | 33436 KB | Output is correct |
22 | Correct | 19 ms | 33436 KB | Output is correct |
23 | Correct | 16 ms | 33436 KB | Output is correct |
24 | Correct | 13 ms | 33436 KB | Output is correct |
25 | Correct | 23 ms | 33436 KB | Output is correct |