# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
162242 | jjwdi0 | 스트랩 (JOI14_straps) | C++11 | 104 ms | 31868 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |