# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
39692 | 14kg | 스트랩 (JOI14_straps) | C++11 | 13 ms | 1136 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <algorithm>
#define INF 2000000000
#define max2(x,y) (x>y?x:y)
#define min2(x,y) (x<y?x:y)
using namespace std;
int n, dp[2001];
pair<int, int> in[2001];
int main() {
int x, y, w, out = 0;
scanf("%d", &n);
for (int i = 2; i <= n; i++) dp[i] = -INF;
for (int i = 1; i <= n; i++) scanf("%d %d", &in[i].first, &in[i].second);
sort(in + 1, in + n + 1);
for (int k = n; k >= 1; k--) {
x = in[k].first - 1, y = in[k].second;
if (x < 0) {
for (int i = 0; i < n; i++) dp[i] = max2(dp[i], dp[i + 1] + y);
}
else {
for (int i = n; i >= 0; i--) {
w = min2(n, i + x);
dp[w] = max2(dp[w], dp[i] + y);
}
}
}
for (int i = 0; i <= n; i++) out = max2(out, dp[i]);
printf("%d", out);
}
컴파일 시 표준 에러 (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... |