# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
25551 | 2017-06-23T04:22:50 Z | 김현수(#1073) | 스트랩 (JOI14_straps) | C++11 | 29 ms | 33456 KB |
#include<bits/stdc++.h> #define X first #define Y second using namespace std; typedef long long ll; const ll inf = 1e18; ll n, dt[2005][2005]; pair<ll,ll> a[2005]; int main() { scanf("%lld",&n); for(ll i=1;i<=n;i++) { scanf("%lld%lld",&a[i].X,&a[i].Y); a[i].X *= -1; } sort(a+1, a+1+n); for(ll i=1;i<=n;i++) a[i].X *= -1; for(ll i=0;i<=n;i++) { for(ll j=0;j<=n;j++) dt[i][j] = -inf; } dt[0][1] = 0; for(ll i=1;i<=n;i++) { dt[i][0] = dt[i-1][0]; for(ll j=1;j<=n;j++) { dt[i][j] = max(dt[i][j], dt[i-1][j]); if(j + a[i].X - 1 >= 0) { ll X = min(n, j+a[i].X-1); dt[i][X] = max(dt[i][X], dt[i-1][j] + a[i].Y); } } } ll ans = 0; for(ll i=0;i<=n;i++) ans = max(ans, dt[n][i]); printf("%lld\n",ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 33456 KB | Output is correct |
2 | Correct | 0 ms | 33456 KB | Output is correct |
3 | Correct | 0 ms | 33456 KB | Output is correct |
4 | Correct | 0 ms | 33456 KB | Output is correct |
5 | Correct | 0 ms | 33456 KB | Output is correct |
6 | Correct | 0 ms | 33456 KB | Output is correct |
7 | Correct | 0 ms | 33456 KB | Output is correct |
8 | Correct | 0 ms | 33456 KB | Output is correct |
9 | Correct | 0 ms | 33456 KB | Output is correct |
10 | Correct | 0 ms | 33456 KB | Output is correct |
11 | Correct | 0 ms | 33456 KB | Output is correct |
12 | Correct | 0 ms | 33456 KB | Output is correct |
13 | Correct | 0 ms | 33456 KB | Output is correct |
14 | Correct | 0 ms | 33456 KB | Output is correct |
15 | Correct | 0 ms | 33456 KB | Output is correct |
16 | Correct | 0 ms | 33456 KB | Output is correct |
17 | Correct | 0 ms | 33456 KB | Output is correct |
18 | Correct | 0 ms | 33456 KB | Output is correct |
19 | Correct | 0 ms | 33456 KB | Output is correct |
20 | Correct | 0 ms | 33456 KB | Output is correct |
21 | Correct | 0 ms | 33456 KB | Output is correct |
22 | Correct | 0 ms | 33456 KB | Output is correct |
23 | Correct | 0 ms | 33456 KB | Output is correct |
24 | Correct | 0 ms | 33456 KB | Output is correct |
25 | Correct | 0 ms | 33456 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 33456 KB | Output is correct |
2 | Correct | 0 ms | 33456 KB | Output is correct |
3 | Correct | 0 ms | 33456 KB | Output is correct |
4 | Correct | 0 ms | 33456 KB | Output is correct |
5 | Correct | 0 ms | 33456 KB | Output is correct |
6 | Correct | 0 ms | 33456 KB | Output is correct |
7 | Correct | 0 ms | 33456 KB | Output is correct |
8 | Correct | 6 ms | 33456 KB | Output is correct |
9 | Correct | 6 ms | 33456 KB | Output is correct |
10 | Correct | 3 ms | 33456 KB | Output is correct |
11 | Correct | 3 ms | 33456 KB | Output is correct |
12 | Correct | 9 ms | 33456 KB | Output is correct |
13 | Correct | 16 ms | 33456 KB | Output is correct |
14 | Correct | 13 ms | 33456 KB | Output is correct |
15 | Correct | 19 ms | 33456 KB | Output is correct |
16 | Correct | 26 ms | 33456 KB | Output is correct |
17 | Correct | 13 ms | 33456 KB | Output is correct |
18 | Correct | 16 ms | 33456 KB | Output is correct |
19 | Correct | 19 ms | 33456 KB | Output is correct |
20 | Correct | 16 ms | 33456 KB | Output is correct |
21 | Correct | 13 ms | 33456 KB | Output is correct |
22 | Correct | 13 ms | 33456 KB | Output is correct |
23 | Correct | 16 ms | 33456 KB | Output is correct |
24 | Correct | 19 ms | 33456 KB | Output is correct |
25 | Correct | 19 ms | 33456 KB | Output is correct |
26 | Correct | 13 ms | 33456 KB | Output is correct |
27 | Correct | 19 ms | 33456 KB | Output is correct |
28 | Correct | 16 ms | 33456 KB | Output is correct |
29 | Correct | 13 ms | 33456 KB | Output is correct |
30 | Correct | 16 ms | 33456 KB | Output is correct |
31 | Correct | 16 ms | 33456 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 33456 KB | Output is correct |
2 | Correct | 0 ms | 33456 KB | Output is correct |
3 | Correct | 0 ms | 33456 KB | Output is correct |
4 | Correct | 0 ms | 33456 KB | Output is correct |
5 | Correct | 0 ms | 33456 KB | Output is correct |
6 | Correct | 0 ms | 33456 KB | Output is correct |
7 | Correct | 0 ms | 33456 KB | Output is correct |
8 | Correct | 0 ms | 33456 KB | Output is correct |
9 | Correct | 6 ms | 33456 KB | Output is correct |
10 | Correct | 3 ms | 33456 KB | Output is correct |
11 | Correct | 3 ms | 33456 KB | Output is correct |
12 | Correct | 6 ms | 33456 KB | Output is correct |
13 | Correct | 6 ms | 33456 KB | Output is correct |
14 | Correct | 3 ms | 33456 KB | Output is correct |
15 | Correct | 6 ms | 33456 KB | Output is correct |
16 | Correct | 13 ms | 33456 KB | Output is correct |
17 | Correct | 19 ms | 33456 KB | Output is correct |
18 | Correct | 16 ms | 33456 KB | Output is correct |
19 | Correct | 29 ms | 33456 KB | Output is correct |
20 | Correct | 19 ms | 33456 KB | Output is correct |
21 | Correct | 13 ms | 33456 KB | Output is correct |
22 | Correct | 9 ms | 33456 KB | Output is correct |
23 | Correct | 13 ms | 33456 KB | Output is correct |
24 | Correct | 9 ms | 33456 KB | Output is correct |
25 | Correct | 16 ms | 33456 KB | Output is correct |
26 | Correct | 19 ms | 33456 KB | Output is correct |
27 | Correct | 13 ms | 33456 KB | Output is correct |
28 | Correct | 16 ms | 33456 KB | Output is correct |
29 | Correct | 13 ms | 33456 KB | Output is correct |
30 | Correct | 16 ms | 33456 KB | Output is correct |
31 | Correct | 13 ms | 33456 KB | Output is correct |
32 | Correct | 16 ms | 33456 KB | Output is correct |
33 | Correct | 23 ms | 33456 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 33456 KB | Output is correct |
2 | Correct | 16 ms | 33456 KB | Output is correct |
3 | Correct | 16 ms | 33456 KB | Output is correct |
4 | Correct | 13 ms | 33456 KB | Output is correct |
5 | Correct | 19 ms | 33456 KB | Output is correct |
6 | Correct | 9 ms | 33456 KB | Output is correct |
7 | Correct | 26 ms | 33456 KB | Output is correct |
8 | Correct | 23 ms | 33456 KB | Output is correct |
9 | Correct | 16 ms | 33456 KB | Output is correct |
10 | Correct | 16 ms | 33456 KB | Output is correct |
11 | Correct | 16 ms | 33456 KB | Output is correct |
12 | Correct | 23 ms | 33456 KB | Output is correct |
13 | Correct | 13 ms | 33456 KB | Output is correct |
14 | Correct | 13 ms | 33456 KB | Output is correct |
15 | Correct | 23 ms | 33456 KB | Output is correct |
16 | Correct | 9 ms | 33456 KB | Output is correct |
17 | Correct | 19 ms | 33456 KB | Output is correct |
18 | Correct | 13 ms | 33456 KB | Output is correct |
19 | Correct | 16 ms | 33456 KB | Output is correct |
20 | Correct | 19 ms | 33456 KB | Output is correct |
21 | Correct | 16 ms | 33456 KB | Output is correct |
22 | Correct | 13 ms | 33456 KB | Output is correct |
23 | Correct | 16 ms | 33456 KB | Output is correct |
24 | Correct | 16 ms | 33456 KB | Output is correct |
25 | Correct | 13 ms | 33456 KB | Output is correct |