# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
162241 | jjwdi0 | 스트랩 (JOI14_straps) | C++11 | 28 ms | 16120 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][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)
# | 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... |