Submission #25191

# Submission time Handle Problem Language Result Execution time Memory
25191 2017-06-20T16:28:05 Z junodeveloper 스트랩 (JOI14_straps) C++14
100 / 100
13 ms 17692 KB
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#define INF (int)2e9
using namespace std;
int e[2002][2002];
pair<int, int> p[2002];
int main() {
    int n, i;
    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        scanf("%d%d", &p[i].first, &p[i].second);
        p[i].first *= -1;
        p[i].second *= -1;
    }
    sort(p + 1, p + n + 1);
    for (i = 2; i <= n; i++) e[0][i] = -INF;
    for (i = 1; i <= n; i++) {
        int a = -p[i].first;
        int b = -p[i].second;
        if (!a) break;
        for (int j = n; j >= 0; j--) {
            e[i][j] = e[i - 1][j];
            int t = max(0, j - a + 1);
            if (e[i - 1][t] != -INF)
                e[i][j] = max(e[i][j], e[i - 1][t] + b);
        }
    }
    int last = i - 1;
    vector<int> v;
    for (; i <= n; i++)
        if (-p[i].second > 0) v.push_back(-p[i].second);
    int res = -INF, sum = 0;
    for (i = 0; i <= n; i++) {
        res = max(res, e[last][i] + sum);
        if (i < v.size()) sum += v[i];
    }
    printf("%d", res);
    return 0;
}

Compilation message

straps.cpp: In function 'int main()':
straps.cpp:37:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (i < v.size()) sum += v[i];
               ^
straps.cpp:11:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
straps.cpp:13:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &p[i].first, &p[i].second);
                                                 ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 17692 KB Output is correct
2 Correct 0 ms 17692 KB Output is correct
3 Correct 0 ms 17692 KB Output is correct
4 Correct 0 ms 17692 KB Output is correct
5 Correct 0 ms 17692 KB Output is correct
6 Correct 0 ms 17692 KB Output is correct
7 Correct 0 ms 17692 KB Output is correct
8 Correct 0 ms 17692 KB Output is correct
9 Correct 0 ms 17692 KB Output is correct
10 Correct 0 ms 17692 KB Output is correct
11 Correct 0 ms 17692 KB Output is correct
12 Correct 0 ms 17692 KB Output is correct
13 Correct 0 ms 17692 KB Output is correct
14 Correct 0 ms 17692 KB Output is correct
15 Correct 0 ms 17692 KB Output is correct
16 Correct 0 ms 17692 KB Output is correct
17 Correct 0 ms 17692 KB Output is correct
18 Correct 0 ms 17692 KB Output is correct
19 Correct 0 ms 17692 KB Output is correct
20 Correct 0 ms 17692 KB Output is correct
21 Correct 0 ms 17692 KB Output is correct
22 Correct 0 ms 17692 KB Output is correct
23 Correct 0 ms 17692 KB Output is correct
24 Correct 0 ms 17692 KB Output is correct
25 Correct 0 ms 17692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 17692 KB Output is correct
2 Correct 0 ms 17692 KB Output is correct
3 Correct 0 ms 17692 KB Output is correct
4 Correct 0 ms 17692 KB Output is correct
5 Correct 0 ms 17692 KB Output is correct
6 Correct 0 ms 17692 KB Output is correct
7 Correct 0 ms 17692 KB Output is correct
8 Correct 3 ms 17692 KB Output is correct
9 Correct 0 ms 17692 KB Output is correct
10 Correct 0 ms 17692 KB Output is correct
11 Correct 0 ms 17692 KB Output is correct
12 Correct 0 ms 17692 KB Output is correct
13 Correct 3 ms 17692 KB Output is correct
14 Correct 3 ms 17692 KB Output is correct
15 Correct 3 ms 17692 KB Output is correct
16 Correct 0 ms 17692 KB Output is correct
17 Correct 0 ms 17692 KB Output is correct
18 Correct 3 ms 17692 KB Output is correct
19 Correct 0 ms 17692 KB Output is correct
20 Correct 0 ms 17692 KB Output is correct
21 Correct 0 ms 17692 KB Output is correct
22 Correct 0 ms 17692 KB Output is correct
23 Correct 0 ms 17692 KB Output is correct
24 Correct 0 ms 17692 KB Output is correct
25 Correct 0 ms 17692 KB Output is correct
26 Correct 0 ms 17692 KB Output is correct
27 Correct 0 ms 17692 KB Output is correct
28 Correct 0 ms 17692 KB Output is correct
29 Correct 6 ms 17692 KB Output is correct
30 Correct 6 ms 17692 KB Output is correct
31 Correct 13 ms 17692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 17692 KB Output is correct
2 Correct 0 ms 17692 KB Output is correct
3 Correct 0 ms 17692 KB Output is correct
4 Correct 0 ms 17692 KB Output is correct
5 Correct 0 ms 17692 KB Output is correct
6 Correct 0 ms 17692 KB Output is correct
7 Correct 0 ms 17692 KB Output is correct
8 Correct 0 ms 17692 KB Output is correct
9 Correct 0 ms 17692 KB Output is correct
10 Correct 0 ms 17692 KB Output is correct
11 Correct 0 ms 17692 KB Output is correct
12 Correct 0 ms 17692 KB Output is correct
13 Correct 0 ms 17692 KB Output is correct
14 Correct 0 ms 17692 KB Output is correct
15 Correct 0 ms 17692 KB Output is correct
16 Correct 0 ms 17692 KB Output is correct
17 Correct 3 ms 17692 KB Output is correct
18 Correct 0 ms 17692 KB Output is correct
19 Correct 0 ms 17692 KB Output is correct
20 Correct 3 ms 17692 KB Output is correct
21 Correct 3 ms 17692 KB Output is correct
22 Correct 0 ms 17692 KB Output is correct
23 Correct 0 ms 17692 KB Output is correct
24 Correct 3 ms 17692 KB Output is correct
25 Correct 0 ms 17692 KB Output is correct
26 Correct 0 ms 17692 KB Output is correct
27 Correct 0 ms 17692 KB Output is correct
28 Correct 0 ms 17692 KB Output is correct
29 Correct 0 ms 17692 KB Output is correct
30 Correct 0 ms 17692 KB Output is correct
31 Correct 0 ms 17692 KB Output is correct
32 Correct 0 ms 17692 KB Output is correct
33 Correct 9 ms 17692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 17692 KB Output is correct
2 Correct 0 ms 17692 KB Output is correct
3 Correct 0 ms 17692 KB Output is correct
4 Correct 0 ms 17692 KB Output is correct
5 Correct 0 ms 17692 KB Output is correct
6 Correct 0 ms 17692 KB Output is correct
7 Correct 0 ms 17692 KB Output is correct
8 Correct 0 ms 17692 KB Output is correct
9 Correct 0 ms 17692 KB Output is correct
10 Correct 0 ms 17692 KB Output is correct
11 Correct 0 ms 17692 KB Output is correct
12 Correct 0 ms 17692 KB Output is correct
13 Correct 0 ms 17692 KB Output is correct
14 Correct 0 ms 17692 KB Output is correct
15 Correct 0 ms 17692 KB Output is correct
16 Correct 0 ms 17692 KB Output is correct
17 Correct 0 ms 17692 KB Output is correct
18 Correct 0 ms 17692 KB Output is correct
19 Correct 6 ms 17692 KB Output is correct
20 Correct 13 ms 17692 KB Output is correct
21 Correct 6 ms 17692 KB Output is correct
22 Correct 13 ms 17692 KB Output is correct
23 Correct 13 ms 17692 KB Output is correct
24 Correct 0 ms 17692 KB Output is correct
25 Correct 0 ms 17692 KB Output is correct