Submission #866334

#TimeUsernameProblemLanguageResultExecution timeMemory
866334phuxtrohhgKnapsack (NOI18_knapsack)C++17
0 / 100
2 ms348 KiB
#include <bits/stdc++.h> #define ll long long #define pii pair<ll, ll> #define st first #define nd second #define all(x) (x).begin(), (x).end() #define mp(x) make_pair(x) #define file "test" using namespace std; const double PI = 2 * acos(0); const long long INF = 1e18; const long long N = 2e6 + 5; ll s, n, v[N], w[N], k[N]; ll dp[3000][3000]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE freopen(file".inp","r",stdin); freopen(file".out","w",stdout); #endif cin >> s >> n; for (int i = 1; i <=n; i++) cin >> v[i] >> w[i] >> k[i]; // for (int i = 1; i <=n; i++) // for (int j = 1; j <= s; j++) // dp[i][j] = INF; for (int i = 1; i <=n; i++) for (int j = 1; j <= s; j++) { for (int sl = 1; w[i] * sl <= j && sl <= k[i]; sl++) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i] * sl] + v[i] * sl); dp[i][j] = max(dp[i][j], dp[i - 1][j]); } // for (int i = 1; i <=n; i++) // { // for (int j = 1; j <= s; j++) // cout << dp[i][j] <<' '; // cout << '\n'; // } cout << dp[n][s]; }

Compilation message (stderr)

knapsack.cpp: In function 'int main()':
knapsack.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen(file".inp","r",stdin); freopen(file".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
knapsack.cpp:19:47: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen(file".inp","r",stdin); freopen(file".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...