| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 537113 | rainboy | 스트랩 (JOI14_straps) | C11 | 21 ms | 436 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 <stdio.h>
#include <string.h>
#define N 2000
#define INF 0x7fffffff
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int main() {
static int dp[N + N + 1], dq[N + N + 1];
int n, i, s, t, ans;
scanf("%d", &n);
for (s = -n; s <= n; s++)
dp[n + s] = -INF;
dp[n + 1] = 0;
for (i = 0; i < n; i++) {
int a, b;
scanf("%d%d", &a, &b), a--;
memcpy(dq, dp, (n * 2 + 1) * sizeof *dp);
for (s = -n; s <= n; s++) {
int x = dq[n + s];
if (x == -INF)
continue;
t = min(s + a, n);
dp[n + t] = max(dp[n + t], x + b);
}
}
ans = -INF;
for (s = 0; s <= n; s++)
ans = max(ans, dp[n + s]);
printf("%d\n", ans);
return 0;
}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... | ||||
