Submission #896684

#TimeUsernameProblemLanguageResultExecution timeMemory
896684blackslexKnapsack (NOI18_knapsack)C++17
37 / 100
1056 ms440 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int M = 2005; ll n, m, dp[M]; int main() { scanf("%lld %lld", &m, &n); vector<ll> w(n), v(n), k(n); for (int i = 0; i < n; i++) scanf("%lld %lld %lld", &v[i], &w[i], &k[i]); for (int i = 0; i < n; i++) while (k[i]--) for (int j = m; j >= 0; j--) if (j - w[i] >= 0) dp[j] = max(dp[j], dp[j - w[i]] + v[i]); printf("%lld", dp[m]); }

Compilation message (stderr)

knapsack.cpp: In function 'int main()':
knapsack.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%lld %lld", &m, &n);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
knapsack.cpp:12:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for (int i = 0; i < n; i++) scanf("%lld %lld %lld", &v[i], &w[i], &k[i]);
      |                                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...