Submission #12871

# Submission time Handle Problem Language Result Execution time Memory
12871 2015-01-15T06:55:22 Z tncks0121 스트랩 (JOI14_straps) C++14
45 / 100
28 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)1e10;
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 = x + (a - 1);
            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 Incorrect 0 ms 1740 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 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 28 ms 1740 KB Output is correct
13 Correct 24 ms 1740 KB Output is correct
14 Correct 28 ms 1740 KB Output is correct
15 Correct 28 ms 1740 KB Output is correct
16 Correct 28 ms 1740 KB Output is correct
17 Correct 28 ms 1740 KB Output is correct
18 Correct 28 ms 1740 KB Output is correct
19 Correct 28 ms 1740 KB Output is correct
20 Correct 28 ms 1740 KB Output is correct
21 Correct 28 ms 1740 KB Output is correct
22 Correct 28 ms 1740 KB Output is correct
23 Runtime error 12 ms 1736 KB SIGSEGV Segmentation fault
24 Halted 0 ms 0 KB -
# 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 4 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 8 ms 1740 KB Output is correct
13 Correct 8 ms 1740 KB Output is correct
14 Correct 4 ms 1740 KB Output is correct
15 Correct 8 ms 1740 KB Output is correct
16 Correct 4 ms 1740 KB Output is correct
17 Correct 28 ms 1740 KB Output is correct
18 Correct 24 ms 1740 KB Output is correct
19 Correct 28 ms 1740 KB Output is correct
20 Correct 28 ms 1740 KB Output is correct
21 Correct 28 ms 1740 KB Output is correct
22 Correct 28 ms 1740 KB Output is correct
23 Correct 28 ms 1740 KB Output is correct
24 Correct 28 ms 1740 KB Output is correct
25 Correct 24 ms 1740 KB Output is correct
26 Correct 24 ms 1740 KB Output is correct
27 Correct 28 ms 1740 KB Output is correct
28 Correct 28 ms 1740 KB Output is correct
29 Correct 28 ms 1740 KB Output is correct
30 Correct 28 ms 1740 KB Output is correct
31 Correct 24 ms 1740 KB Output is correct
32 Correct 28 ms 1740 KB Output is correct
33 Correct 28 ms 1740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1740 KB Output is correct
2 Correct 24 ms 1740 KB Output is correct
3 Correct 28 ms 1740 KB Output is correct
4 Correct 28 ms 1740 KB Output is correct
5 Correct 28 ms 1740 KB Output is correct
6 Runtime error 12 ms 1736 KB SIGSEGV Segmentation fault
7 Halted 0 ms 0 KB -