# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
159749 | 2019-10-24T12:26:30 Z | geon040702 | None (KOI17_travel) | C++14 | 70 ms | 26872 KB |
#include <bits/stdc++.h> using namespace std; #define MAXN 100 #define MAXK 100000 int DP[MAXN+1][MAXK+1]; int vis[MAXN+1][MAXK+1]; int W_time[MAXN]; int W_money[MAXN]; int B_time[MAXN]; int B_money[MAXN]; int N, K, ans; int main(void) { int i, j; scanf("%d%d", &N, &K); for(i=0;i<N;i++) { scanf("%d%d%d%d", &W_time[i], &W_money[i], &B_time[i], &B_money[i]); } vis[0][0] = 1; for(i=0;i<N;i++) { for(j=0;j<=K;j++) { if(vis[i][j] == 0) { continue; } if(j + W_time[i] <= K) { DP[i+1][j+W_time[i]] = max(DP[i+1][j+W_time[i]], DP[i][j] + W_money[i]); vis[i+1][j+W_time[i]] = 1; } if(j + B_time[i] <= K) { DP[i+1][j+B_time[i]] = max(DP[i+1][j+B_time[i]], DP[i][j] + B_money[i]); vis[i+1][j+B_time[i]] = 1; } } } for(j=0;j<=K;j++){ ans = max(ans, DP[N][j]); } printf("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 632 KB | Output is correct |
7 | Correct | 2 ms | 632 KB | Output is correct |
8 | Correct | 3 ms | 760 KB | Output is correct |
9 | Correct | 3 ms | 760 KB | Output is correct |
10 | Correct | 2 ms | 636 KB | Output is correct |
11 | Correct | 2 ms | 380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 632 KB | Output is correct |
7 | Correct | 2 ms | 632 KB | Output is correct |
8 | Correct | 3 ms | 760 KB | Output is correct |
9 | Correct | 3 ms | 760 KB | Output is correct |
10 | Correct | 2 ms | 636 KB | Output is correct |
11 | Correct | 2 ms | 380 KB | Output is correct |
12 | Correct | 22 ms | 8312 KB | Output is correct |
13 | Correct | 37 ms | 14456 KB | Output is correct |
14 | Correct | 62 ms | 22776 KB | Output is correct |
15 | Correct | 63 ms | 23352 KB | Output is correct |
16 | Correct | 67 ms | 24660 KB | Output is correct |
17 | Correct | 70 ms | 26872 KB | Output is correct |
18 | Correct | 62 ms | 23360 KB | Output is correct |
19 | Correct | 68 ms | 25436 KB | Output is correct |
20 | Correct | 62 ms | 22776 KB | Output is correct |