Submission #533633

#TimeUsernameProblemLanguageResultExecution timeMemory
533633900iqNoobieKnapsack (NOI18_knapsack)C++17
0 / 100
108 ms95136 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; int const mod=998244353; ll dp[2002][2002]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t=1; //cin>>t; while (t--){ int n,s,va,w,k; cin>>s>>n; vector <pair<int,int>> v; v.push_back({0,0}); for (int i=0;i<n;i++){ cin>>va>>w>>k; while (k--) v.push_back({va,w}); } dp[0][0]=0; for (int i=1;i<v.size();i++){ for (int j=0;j<=s;j++){ dp[i][j]=dp[i-1][j]; if (v[j].second<j) dp[i][j]=max(dp[i][j],dp[i-1][j-v[j].second]+v[j].second); } } cout<<dp[n][s]<<"\n"; } return 0; }

Compilation message (stderr)

knapsack.cpp: In function 'int main()':
knapsack.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for (int i=1;i<v.size();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...