Submission #484007

#TimeUsernameProblemLanguageResultExecution timeMemory
484007T0p_Knapsack (NOI18_knapsack)C++14
12 / 100
0 ms204 KiB
#include <bits/stdc++.h> using namespace std; long long dp[2][2005]; int main() { int s, n; scanf(" %d %d",&s,&n); for(int i=1 ; i<=n ; i++) { int w, k; long long v; scanf(" %lld %d %d",&v,&w,&k); for(int j=1 ; j<=s ; j++) { dp[i%2][j] = dp[i%2][j-1]; for(long long t=1 ; t<=k && j-w*t>=0 ; t++) dp[i%2][j] = max(dp[i%2][j], dp[(i-1)%2][j-w*t] + v*t); } } printf("%lld\n",dp[n%2][s]); return 0; }

Compilation message (stderr)

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