Submission #162242

#TimeUsernameProblemLanguageResultExecution timeMemory
162242jjwdi0스트랩 (JOI14_straps)C++11
100 / 100
104 ms31868 KiB
#include <bits/stdc++.h> using namespace std; int N, A[2005], B[2005], D[2005][4005]; 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+N; j++) D[i][j] = -1e9; D[0][N+1] = 0; int ans = 0; for(int i=0; i<N; i++) for(int j=0; j<=N+N; j++) { int k = min(N+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][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...