제출 #984291

#제출 시각아이디문제언어결과실행 시간메모리
984291duyanhloveavKnapsack (NOI18_knapsack)C++14
73 / 100
1073 ms1368 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mxn = 9 + 1e6; const int inf = 0x3f3f3f3f; const ll lnf = 0x3f3f3f3f3f3f3f3f; void SaKaTa(void) { int s, n; cin >> s >> n; vector<int> dp(s + 1), dp2 = dp; for (int i = 0; i < n; ++i) { int v, w, k; cin >> v >> w >> k; dp2 = dp; for (int l = 1; l <= k; ++l) { if (w * l > s) break; for (int j = s; j >= w * l; --j) { dp[j] = max(dp[j], dp2[j - w * l] + v * l); } } } cout << *max_element(begin(dp), end(dp)); } int32_t main(void) { #define task "SaKaTa" cin.tie(0)->sync_with_stdio(0); for (string iext : {"in", "inp"}) { if (fopen((task "." + iext).c_str(), "r")) { freopen((task "." + iext).c_str(), "r", stdin); freopen(task ".out", "w", stdout); } } int testcase = 1; // cin >> testcase; while (testcase--) SaKaTa(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

knapsack.cpp: In function 'int32_t main()':
knapsack.cpp:33:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |       freopen((task "." + iext).c_str(), "r", stdin);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
knapsack.cpp:34:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |       freopen(task ".out", "w", stdout);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...