| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 917338 | rainboy | 서울에서 경산까지 (KOI17_travel) | C11 | 13 ms | 816 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <string.h>
#define W	100000
int max(int a, int b) { return a > b ? a : b; }
int main() {
	static int dp[W + 1];
	int n, w, s, x;
	scanf("%d%d", &n, &w);
	memset(dp, -1, (w + 1) * sizeof *dp), dp[0] = 0;
	while (n--) {
		int w1, v1, w2, v2;
		scanf("%d%d%d%d", &w1, &v1, &w2, &v2);
		for (s = w; s >= 0; s--) {
			x = dp[s];
			if (x == -1)
				continue;
			dp[s] = -1;
			if (s + w1 <= w)
				dp[s + w1] = max(dp[s + w1], x + v1);
			if (s + w2 <= w)
				dp[s + w2] = max(dp[s + w2], x + v2);
		}
	}
	x = -1;
	for (s = 0; s <= w; s++)
		x = max(x, dp[s]);
	printf("%d\n", x);
	return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
