Submission #159749

#TimeUsernameProblemLanguageResultExecution timeMemory
159749geon040702서울에서 경산까지 (KOI17_travel)C++14
100 / 100
70 ms26872 KiB
#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)

travel.cpp: In function 'int main()':
travel.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &K);
     ~~~~~^~~~~~~~~~~~~~~~
travel.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d%d", &W_time[i], &W_money[i], &B_time[i], &B_money[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...