답안 #25553

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
25553 2017-06-23T04:41:12 Z 시제연(#1075) 스트랩 (JOI14_straps) C++
45 / 100
49 ms 85708 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll knap[2100][5100], INF = 1LL<<50;
int n, bia = 2010;
int a[2100], b[2100];

int main() {
    int i, j;

    //freopen("input","r",stdin);

    scanf("%d",&n);
    for (i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
    for (i=1;i<=n;i++) a[i]--;
    for (j=0;j<5100;j++) knap[0][j] = -INF;
    knap[0][bia] = 0;
    ll res = 0;
    for (i=1;i<=n;i++) {
        for (j=0;j<=n+bia+1;j++) {
            knap[i][j] = knap[i-1][j];
            if (j==n+bia+1) knap[i][j] = max(knap[i][j],knap[i-1][j]+b[i]);
            if (j-a[i]>=0&&j-a[i]<=n+bia) knap[i][j] = max(knap[i][j],knap[i-1][j-a[i]]+b[i]);
            if (i==n&&j-bia>=-1) res = max(res,knap[i][j]);
        }
    }
    printf("%lld\n",res);

    return 0;
}

Compilation message

straps.cpp: In function 'int main()':
straps.cpp:16:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
straps.cpp:17:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
                                                 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 85708 KB Output is correct
2 Correct 0 ms 85708 KB Output is correct
3 Correct 0 ms 85708 KB Output is correct
4 Correct 0 ms 85708 KB Output is correct
5 Correct 0 ms 85708 KB Output is correct
6 Correct 0 ms 85708 KB Output is correct
7 Correct 0 ms 85708 KB Output is correct
8 Correct 0 ms 85708 KB Output is correct
9 Correct 0 ms 85708 KB Output is correct
10 Correct 0 ms 85708 KB Output is correct
11 Correct 0 ms 85708 KB Output is correct
12 Correct 0 ms 85708 KB Output is correct
13 Correct 0 ms 85708 KB Output is correct
14 Correct 0 ms 85708 KB Output is correct
15 Correct 0 ms 85708 KB Output is correct
16 Correct 0 ms 85708 KB Output is correct
17 Correct 0 ms 85708 KB Output is correct
18 Correct 0 ms 85708 KB Output is correct
19 Correct 0 ms 85708 KB Output is correct
20 Correct 0 ms 85708 KB Output is correct
21 Correct 0 ms 85708 KB Output is correct
22 Correct 0 ms 85708 KB Output is correct
23 Correct 0 ms 85708 KB Output is correct
24 Correct 0 ms 85708 KB Output is correct
25 Incorrect 0 ms 85708 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 85708 KB Output is correct
2 Correct 0 ms 85708 KB Output is correct
3 Correct 0 ms 85708 KB Output is correct
4 Correct 0 ms 85708 KB Output is correct
5 Correct 0 ms 85708 KB Output is correct
6 Correct 0 ms 85708 KB Output is correct
7 Correct 0 ms 85708 KB Output is correct
8 Correct 9 ms 85708 KB Output is correct
9 Correct 9 ms 85708 KB Output is correct
10 Correct 16 ms 85708 KB Output is correct
11 Correct 6 ms 85708 KB Output is correct
12 Correct 23 ms 85708 KB Output is correct
13 Correct 19 ms 85708 KB Output is correct
14 Correct 36 ms 85708 KB Output is correct
15 Correct 26 ms 85708 KB Output is correct
16 Correct 33 ms 85708 KB Output is correct
17 Correct 49 ms 85708 KB Output is correct
18 Correct 13 ms 85708 KB Output is correct
19 Correct 19 ms 85708 KB Output is correct
20 Correct 19 ms 85708 KB Output is correct
21 Correct 6 ms 85708 KB Output is correct
22 Correct 19 ms 85708 KB Output is correct
23 Correct 19 ms 85708 KB Output is correct
24 Correct 26 ms 85708 KB Output is correct
25 Correct 19 ms 85708 KB Output is correct
26 Correct 19 ms 85708 KB Output is correct
27 Correct 29 ms 85708 KB Output is correct
28 Correct 13 ms 85708 KB Output is correct
29 Incorrect 23 ms 85708 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 85708 KB Output is correct
2 Correct 0 ms 85708 KB Output is correct
3 Correct 0 ms 85708 KB Output is correct
4 Correct 0 ms 85708 KB Output is correct
5 Correct 0 ms 85708 KB Output is correct
6 Correct 0 ms 85708 KB Output is correct
7 Correct 0 ms 85708 KB Output is correct
8 Correct 0 ms 85708 KB Output is correct
9 Correct 16 ms 85708 KB Output is correct
10 Correct 3 ms 85708 KB Output is correct
11 Correct 6 ms 85708 KB Output is correct
12 Correct 9 ms 85708 KB Output is correct
13 Correct 3 ms 85708 KB Output is correct
14 Correct 13 ms 85708 KB Output is correct
15 Correct 9 ms 85708 KB Output is correct
16 Correct 9 ms 85708 KB Output is correct
17 Correct 36 ms 85708 KB Output is correct
18 Correct 23 ms 85708 KB Output is correct
19 Correct 19 ms 85708 KB Output is correct
20 Correct 16 ms 85708 KB Output is correct
21 Correct 29 ms 85708 KB Output is correct
22 Correct 23 ms 85708 KB Output is correct
23 Correct 19 ms 85708 KB Output is correct
24 Correct 29 ms 85708 KB Output is correct
25 Correct 23 ms 85708 KB Output is correct
26 Correct 16 ms 85708 KB Output is correct
27 Correct 19 ms 85708 KB Output is correct
28 Correct 13 ms 85708 KB Output is correct
29 Correct 26 ms 85708 KB Output is correct
30 Correct 36 ms 85708 KB Output is correct
31 Correct 23 ms 85708 KB Output is correct
32 Correct 23 ms 85708 KB Output is correct
33 Correct 19 ms 85708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 85708 KB Output is correct
2 Correct 29 ms 85708 KB Output is correct
3 Correct 39 ms 85708 KB Output is correct
4 Correct 29 ms 85708 KB Output is correct
5 Correct 29 ms 85708 KB Output is correct
6 Correct 16 ms 85708 KB Output is correct
7 Correct 19 ms 85708 KB Output is correct
8 Correct 19 ms 85708 KB Output is correct
9 Correct 16 ms 85708 KB Output is correct
10 Correct 19 ms 85708 KB Output is correct
11 Incorrect 23 ms 85708 KB Output isn't correct
12 Halted 0 ms 0 KB -