Submission #864579

#TimeUsernameProblemLanguageResultExecution timeMemory
864579thundereyexKnapsack (NOI18_knapsack)C++14
29 / 100
4 ms1884 KiB
#include<bits/stdc++.h> using namespace std; int main(){ long long int n,k; cin>>n>>k; vector<vector<long long int>>v1; vector<long long int>v2; for(int i=0;i<k;i++){ long long int a,b,c; cin>>a>>b>>c; if(b<=n){ long long int g= n/b; // for(int j=0;j<min(g,c);j++){ v2.push_back(a); v2.push_back(b); v2.push_back(min(g,c)); v1.push_back(v2); v2.clear(); // } } // v2.clear(); } vector<vector<long long int>>dp(v1.size()+1,vector<long long int>(n+1,0)); // sort(v1.begin(),v1.end(),greater<vector<int>>()); long long int max1=0; for (int i = 1; i <= v1.size(); i++) for (int j = n; j >= 0; j--) for (int t = 0; t <= v1[i-1][2]; t++) if (j >= v1[i-1][1] * t) { dp[i][j] = max(dp[i-1][j], dp[i-1][j - v1[i-1][1] * t] + v1[i-1][0] * t); max1=max(max1,dp[i][j]); } // for(int i=1;i<=k;i++){ // for(int j=1;j<=n;j++){ // cout<<dp[i][j]<<" "; // } // cout<<endl; // } // cout<<endl; cout<<max1<<endl; }

Compilation message (stderr)

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