# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
12873 |
2015-01-15T06:59:22 Z |
tncks0121 |
스트랩 (JOI14_straps) |
C++14 |
|
40 ms |
1740 KB |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
#include <iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
const int N_ = 2005;
const ll INF = (ll)1e15;
int N;
ll Table[2][N_+N_+50];
#define tb(i, j) Table[(i) & 1][(j) + N_]
ll ans;
void maximize (ll &t, ll v) {
t = max(t, v);
}
int main() {
scanf("%d", &N);
for(int i = -N; i <= N; i++) tb(0, i) = -INF;
tb(0, 0) = 0;
int suma = 0;
for(int r = 1; r <= N; r++) {
int a, b; scanf("%d%d", &a, &b);
for(int i = -N; i <= N; i++) tb(r, i) = tb(r-1, i);
for(int x = -N; x <= N; x++) {
int y = min(x + (a - 1), N);
if(-N <= y && y <= N) maximize(tb(r, y), tb(r - 1, x) + b);
}
}
for(int i = -1; i <= N; i++) ans = max(ans, tb(N, i));
printf("%lld\n", ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1740 KB |
Output is correct |
2 |
Correct |
0 ms |
1740 KB |
Output is correct |
3 |
Correct |
0 ms |
1740 KB |
Output is correct |
4 |
Correct |
0 ms |
1740 KB |
Output is correct |
5 |
Correct |
0 ms |
1740 KB |
Output is correct |
6 |
Correct |
0 ms |
1740 KB |
Output is correct |
7 |
Correct |
0 ms |
1740 KB |
Output is correct |
8 |
Correct |
0 ms |
1740 KB |
Output is correct |
9 |
Correct |
0 ms |
1740 KB |
Output is correct |
10 |
Correct |
0 ms |
1740 KB |
Output is correct |
11 |
Correct |
0 ms |
1740 KB |
Output is correct |
12 |
Correct |
0 ms |
1740 KB |
Output is correct |
13 |
Correct |
0 ms |
1740 KB |
Output is correct |
14 |
Correct |
0 ms |
1740 KB |
Output is correct |
15 |
Correct |
0 ms |
1740 KB |
Output is correct |
16 |
Correct |
0 ms |
1740 KB |
Output is correct |
17 |
Correct |
0 ms |
1740 KB |
Output is correct |
18 |
Correct |
0 ms |
1740 KB |
Output is correct |
19 |
Correct |
0 ms |
1740 KB |
Output is correct |
20 |
Correct |
0 ms |
1740 KB |
Output is correct |
21 |
Correct |
0 ms |
1740 KB |
Output is correct |
22 |
Correct |
0 ms |
1740 KB |
Output is correct |
23 |
Correct |
0 ms |
1740 KB |
Output is correct |
24 |
Correct |
0 ms |
1740 KB |
Output is correct |
25 |
Correct |
0 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1740 KB |
Output is correct |
2 |
Correct |
0 ms |
1740 KB |
Output is correct |
3 |
Correct |
0 ms |
1740 KB |
Output is correct |
4 |
Correct |
0 ms |
1740 KB |
Output is correct |
5 |
Correct |
0 ms |
1740 KB |
Output is correct |
6 |
Correct |
0 ms |
1740 KB |
Output is correct |
7 |
Correct |
0 ms |
1740 KB |
Output is correct |
8 |
Correct |
8 ms |
1740 KB |
Output is correct |
9 |
Correct |
8 ms |
1740 KB |
Output is correct |
10 |
Correct |
8 ms |
1740 KB |
Output is correct |
11 |
Correct |
8 ms |
1740 KB |
Output is correct |
12 |
Correct |
36 ms |
1740 KB |
Output is correct |
13 |
Correct |
36 ms |
1740 KB |
Output is correct |
14 |
Correct |
36 ms |
1740 KB |
Output is correct |
15 |
Correct |
36 ms |
1740 KB |
Output is correct |
16 |
Correct |
36 ms |
1740 KB |
Output is correct |
17 |
Correct |
36 ms |
1740 KB |
Output is correct |
18 |
Correct |
32 ms |
1740 KB |
Output is correct |
19 |
Correct |
36 ms |
1740 KB |
Output is correct |
20 |
Correct |
36 ms |
1740 KB |
Output is correct |
21 |
Correct |
32 ms |
1740 KB |
Output is correct |
22 |
Correct |
36 ms |
1740 KB |
Output is correct |
23 |
Correct |
36 ms |
1740 KB |
Output is correct |
24 |
Correct |
32 ms |
1740 KB |
Output is correct |
25 |
Correct |
36 ms |
1740 KB |
Output is correct |
26 |
Correct |
36 ms |
1740 KB |
Output is correct |
27 |
Correct |
32 ms |
1740 KB |
Output is correct |
28 |
Correct |
36 ms |
1740 KB |
Output is correct |
29 |
Correct |
36 ms |
1740 KB |
Output is correct |
30 |
Correct |
32 ms |
1740 KB |
Output is correct |
31 |
Correct |
36 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1740 KB |
Output is correct |
2 |
Correct |
0 ms |
1740 KB |
Output is correct |
3 |
Correct |
0 ms |
1740 KB |
Output is correct |
4 |
Correct |
0 ms |
1740 KB |
Output is correct |
5 |
Correct |
0 ms |
1740 KB |
Output is correct |
6 |
Correct |
0 ms |
1740 KB |
Output is correct |
7 |
Correct |
0 ms |
1740 KB |
Output is correct |
8 |
Correct |
0 ms |
1740 KB |
Output is correct |
9 |
Correct |
8 ms |
1740 KB |
Output is correct |
10 |
Correct |
8 ms |
1740 KB |
Output is correct |
11 |
Correct |
4 ms |
1740 KB |
Output is correct |
12 |
Correct |
8 ms |
1740 KB |
Output is correct |
13 |
Correct |
8 ms |
1740 KB |
Output is correct |
14 |
Correct |
8 ms |
1740 KB |
Output is correct |
15 |
Correct |
8 ms |
1740 KB |
Output is correct |
16 |
Correct |
8 ms |
1740 KB |
Output is correct |
17 |
Correct |
36 ms |
1740 KB |
Output is correct |
18 |
Correct |
36 ms |
1740 KB |
Output is correct |
19 |
Correct |
36 ms |
1740 KB |
Output is correct |
20 |
Correct |
36 ms |
1740 KB |
Output is correct |
21 |
Correct |
36 ms |
1740 KB |
Output is correct |
22 |
Correct |
36 ms |
1740 KB |
Output is correct |
23 |
Correct |
36 ms |
1740 KB |
Output is correct |
24 |
Correct |
36 ms |
1740 KB |
Output is correct |
25 |
Correct |
36 ms |
1740 KB |
Output is correct |
26 |
Correct |
36 ms |
1740 KB |
Output is correct |
27 |
Correct |
36 ms |
1740 KB |
Output is correct |
28 |
Correct |
36 ms |
1740 KB |
Output is correct |
29 |
Correct |
36 ms |
1740 KB |
Output is correct |
30 |
Correct |
36 ms |
1740 KB |
Output is correct |
31 |
Correct |
36 ms |
1740 KB |
Output is correct |
32 |
Correct |
32 ms |
1740 KB |
Output is correct |
33 |
Correct |
36 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
1740 KB |
Output is correct |
2 |
Correct |
36 ms |
1740 KB |
Output is correct |
3 |
Correct |
36 ms |
1740 KB |
Output is correct |
4 |
Correct |
36 ms |
1740 KB |
Output is correct |
5 |
Correct |
36 ms |
1740 KB |
Output is correct |
6 |
Correct |
36 ms |
1740 KB |
Output is correct |
7 |
Correct |
36 ms |
1740 KB |
Output is correct |
8 |
Correct |
36 ms |
1740 KB |
Output is correct |
9 |
Correct |
36 ms |
1740 KB |
Output is correct |
10 |
Correct |
36 ms |
1740 KB |
Output is correct |
11 |
Correct |
36 ms |
1740 KB |
Output is correct |
12 |
Correct |
32 ms |
1740 KB |
Output is correct |
13 |
Correct |
36 ms |
1740 KB |
Output is correct |
14 |
Correct |
36 ms |
1740 KB |
Output is correct |
15 |
Correct |
36 ms |
1740 KB |
Output is correct |
16 |
Correct |
36 ms |
1740 KB |
Output is correct |
17 |
Correct |
36 ms |
1740 KB |
Output is correct |
18 |
Correct |
36 ms |
1740 KB |
Output is correct |
19 |
Correct |
40 ms |
1740 KB |
Output is correct |
20 |
Correct |
36 ms |
1740 KB |
Output is correct |
21 |
Correct |
36 ms |
1740 KB |
Output is correct |
22 |
Correct |
40 ms |
1740 KB |
Output is correct |
23 |
Correct |
36 ms |
1740 KB |
Output is correct |
24 |
Correct |
36 ms |
1740 KB |
Output is correct |
25 |
Correct |
32 ms |
1740 KB |
Output is correct |