# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
30814 | 2017-07-27T02:35:44 Z | TAMREF | 스트랩 (JOI14_straps) | C++11 | 946 ms | 262144 KB |
#include <bits/stdc++.h> #define ilb INT_MIN using namespace std; unordered_map<int,int> dp[2005], vis[2005]; pair<int,int> 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<pair<int,int>>()); dp[0][1]=0; } void work_dp(){ for(int i=0;i<N;i++){ for(auto x : dp[i]){ if(!vis[i+1][x.first]){ dp[i+1][x.first]=ilb; vis[i+1][x.first]=1; } dp[i+1][x.first]=max(dp[i+1][x.first],x.second); if(!x.first) continue; if(!vis[i+1][x.first+f[i].first-1]){ dp[i+1][x.first+f[i].first-1]=ilb; vis[i+1][x.first+f[i].first-1]=1; } dp[i+1][x.first+f[i].first-1]=max(dp[i+1][x.first+f[i].first-1],x.second+f[i].second); } } } void output(){ int t=0; for(auto x : dp[N]) t=max(t,x.second); printf("%d\n",t); } int main(){ input(); work_dp(); output(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2260 KB | Output is correct |
2 | Correct | 0 ms | 2260 KB | Output is correct |
3 | Correct | 0 ms | 2260 KB | Output is correct |
4 | Correct | 0 ms | 2260 KB | Output is correct |
5 | Correct | 0 ms | 2260 KB | Output is correct |
6 | Correct | 0 ms | 2260 KB | Output is correct |
7 | Correct | 0 ms | 2260 KB | Output is correct |
8 | Correct | 0 ms | 2260 KB | Output is correct |
9 | Correct | 0 ms | 2260 KB | Output is correct |
10 | Correct | 0 ms | 2260 KB | Output is correct |
11 | Correct | 0 ms | 2260 KB | Output is correct |
12 | Correct | 0 ms | 2260 KB | Output is correct |
13 | Correct | 0 ms | 2260 KB | Output is correct |
14 | Correct | 0 ms | 2260 KB | Output is correct |
15 | Correct | 0 ms | 2260 KB | Output is correct |
16 | Correct | 0 ms | 2260 KB | Output is correct |
17 | Correct | 0 ms | 2260 KB | Output is correct |
18 | Correct | 0 ms | 2260 KB | Output is correct |
19 | Correct | 0 ms | 2260 KB | Output is correct |
20 | Correct | 0 ms | 2260 KB | Output is correct |
21 | Correct | 0 ms | 2260 KB | Output is correct |
22 | Correct | 0 ms | 2260 KB | Output is correct |
23 | Correct | 0 ms | 2260 KB | Output is correct |
24 | Correct | 0 ms | 2392 KB | Output is correct |
25 | Correct | 0 ms | 2392 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2260 KB | Output is correct |
2 | Correct | 0 ms | 2392 KB | Output is correct |
3 | Correct | 0 ms | 2392 KB | Output is correct |
4 | Correct | 0 ms | 2392 KB | Output is correct |
5 | Correct | 0 ms | 2524 KB | Output is correct |
6 | Correct | 0 ms | 2392 KB | Output is correct |
7 | Correct | 0 ms | 2524 KB | Output is correct |
8 | Correct | 49 ms | 14932 KB | Output is correct |
9 | Correct | 49 ms | 14008 KB | Output is correct |
10 | Correct | 73 ms | 20080 KB | Output is correct |
11 | Correct | 53 ms | 15460 KB | Output is correct |
12 | Correct | 209 ms | 47008 KB | Output is correct |
13 | Correct | 196 ms | 50440 KB | Output is correct |
14 | Correct | 253 ms | 59020 KB | Output is correct |
15 | Correct | 193 ms | 49252 KB | Output is correct |
16 | Correct | 213 ms | 49648 KB | Output is correct |
17 | Correct | 266 ms | 51100 KB | Output is correct |
18 | Correct | 216 ms | 47272 KB | Output is correct |
19 | Correct | 719 ms | 181028 KB | Output is correct |
20 | Correct | 946 ms | 199956 KB | Output is correct |
21 | Memory limit exceeded | 779 ms | 262144 KB | Memory limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2392 KB | Output is correct |
2 | Correct | 0 ms | 2524 KB | Output is correct |
3 | Correct | 0 ms | 2392 KB | Output is correct |
4 | Correct | 0 ms | 2392 KB | Output is correct |
5 | Correct | 0 ms | 2524 KB | Output is correct |
6 | Correct | 0 ms | 2524 KB | Output is correct |
7 | Correct | 0 ms | 2392 KB | Output is correct |
8 | Correct | 0 ms | 2392 KB | Output is correct |
9 | Correct | 69 ms | 14536 KB | Output is correct |
10 | Correct | 56 ms | 14536 KB | Output is correct |
11 | Correct | 59 ms | 12952 KB | Output is correct |
12 | Correct | 59 ms | 13480 KB | Output is correct |
13 | Correct | 83 ms | 20344 KB | Output is correct |
14 | Correct | 89 ms | 15988 KB | Output is correct |
15 | Correct | 66 ms | 14536 KB | Output is correct |
16 | Correct | 63 ms | 15196 KB | Output is correct |
17 | Correct | 243 ms | 50044 KB | Output is correct |
18 | Correct | 196 ms | 48196 KB | Output is correct |
19 | Correct | 209 ms | 45556 KB | Output is correct |
20 | Correct | 166 ms | 41992 KB | Output is correct |
21 | Correct | 336 ms | 72484 KB | Output is correct |
22 | Correct | 276 ms | 74124 KB | Output is correct |
23 | Correct | 199 ms | 49384 KB | Output is correct |
24 | Correct | 209 ms | 51496 KB | Output is correct |
25 | Correct | 209 ms | 53344 KB | Output is correct |
26 | Correct | 199 ms | 45292 KB | Output is correct |
27 | Correct | 173 ms | 40408 KB | Output is correct |
28 | Correct | 186 ms | 44632 KB | Output is correct |
29 | Correct | 339 ms | 79904 KB | Output is correct |
30 | Correct | 156 ms | 41992 KB | Output is correct |
31 | Correct | 206 ms | 47008 KB | Output is correct |
32 | Correct | 269 ms | 57832 KB | Output is correct |
33 | Correct | 796 ms | 174792 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 659 ms | 162816 KB | Output is correct |
2 | Correct | 733 ms | 161216 KB | Output is correct |
3 | Correct | 756 ms | 191940 KB | Output is correct |
4 | Correct | 489 ms | 112296 KB | Output is correct |
5 | Memory limit exceeded | 879 ms | 262144 KB | Memory limit exceeded |
6 | Halted | 0 ms | 0 KB | - |