답안 #162241

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
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);
                             ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 16120 KB Output isn't correct
2 Halted 0 ms 0 KB -