Submission #162241

# Submission time Handle Problem Language Result Execution time Memory
162241 2019-11-07T09:35:08 Z jjwdi0 스트랩 (JOI14_straps) C++11
0 / 100
28 ms 16120 KB
#include <bits/stdc++.h>
using namespace std;

int N, A[2005], B[2005], D[2005][2005];

int main() {
    scanf("%d", &N);
    for(int i=1; i<=N; i++) scanf("%d %d", A+i, B+i);
    for(int i=0; i<=N; i++) for(int j=0; j<=N; j++) D[i][j] = -1e9;
    D[0][1] = 0;
    int ans = 0;
    for(int i=0; i<N; i++) for(int j=0; j<=N; j++) {
        int k = min(N, j + A[i+1] - 1);
        if(~k) D[i+1][k] = max(D[i+1][k], D[i][j] + B[i+1]);
        D[i+1][j] = max(D[i+1][j], D[i][j]);
    }
    for(int i=0; i<=N; i++) ans = max(ans, D[N][i]);
    printf("%d\n", ans);
}

Compilation message

straps.cpp: In function 'int main()':
straps.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
straps.cpp:8:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=N; i++) scanf("%d %d", A+i, B+i);
                             ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 760 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 888 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Incorrect 3 ms 760 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 16120 KB Output isn't correct
2 Halted 0 ms 0 KB -