제출 #1014516

#제출 시각아이디문제언어결과실행 시간메모리
1014516dizzytapsKnapsack (NOI18_knapsack)C++14
37 / 100
120 ms262144 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int s,n; cin>>s>>n; vector<int> values; vector<int> weights; for(int i=0;i<n;i++){ int val,weight,k; cin>>val>>weight>>k; for(int i=0;i<k;i++){ values.push_back(val); weights.push_back(weight); } } vector<vector<int>> dp(s+1,vector<int>(values.size()+1,0)); for(int i=1;i<=s;i++){ for(int j=1;j<=values.size();j++){ dp[i][j]=dp[i][j-1]; if(i-weights[j-1]>=0) dp[i][j]=max(dp[i][j],dp[i-weights[j-1]][j-1]+values[j-1]); } } cout<<dp[s][values.size()]<<endl; }

컴파일 시 표준 에러 (stderr) 메시지

knapsack.cpp: In function 'int main()':
knapsack.cpp:21:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for(int j=1;j<=values.size();j++){
      |                     ~^~~~~~~~~~~~~~~
#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...