Submission #162241

#TimeUsernameProblemLanguageResultExecution timeMemory
162241jjwdi0스트랩 (JOI14_straps)C++11
0 / 100
28 ms16120 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...