| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 917335 | rainboy | 서울에서 경산까지 (KOI17_travel) | C11 | 10 ms | 1116 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 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;
			dp[s + w1] = max(dp[s + w1], x + v1), dp[s + w2] = max(dp[s + w2], x + v2);
		}
	}
	x = 0;
	for (s = 0; s <= w; s++)
		x = max(x, dp[s]);
	printf("%d\n", x);
	return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
