# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
159749 | geon040702 | 서울에서 경산까지 (KOI17_travel) | C++14 | 70 ms | 26872 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 <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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |