제출 #866234

#제출 시각아이디문제언어결과실행 시간메모리
866234maks007Knapsack (NOI18_knapsack)C++14
73 / 100
203 ms262144 KiB
#include "bits/stdc++.h" using namespace std; //#define int long long signed main () { int W, n; cin >> W >> n; vector <int> v, w; for(int i = 0; i < n; i ++) { int V, WW; cin >> V >> WW; v.push_back(V); w.push_back(WW); int k; cin >> k; k = min(k , W/WW); k--; while(k --) { v.push_back(V); w.push_back(WW); } } vector <int> dp(W+1, -1e9); dp[0] = 0; for(int i = 0; i < v.size(); i ++) { for(int j = W; j >= 0; j --) { if(j-w[i] >= 0) dp[j] = max(dp[j], dp[j-w[i]]+v[i]); } } cout << *max_element(dp.begin(), dp.end()); return 0; }

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

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