이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
straps.c: In function 'main':
straps.c:14:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
straps.c:21:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
21 | scanf("%d%d", &a, &b), a--;
| ^~~~~~~~~~~~~~~~~~~~~
# | 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... |