제출 #1067482

#제출 시각아이디문제언어결과실행 시간메모리
1067482rohanjhaKnapsack (NOI18_knapsack)C++14
37 / 100
1026 ms165368 KiB
#include<iostream> #include<vector> using namespace std; int main(){ int s, n; cin>>s>>n; vector<vector<int> > items; for(int i=0; i<n; i++){ int v, w, k; cin>>v>>w>>k; vector<int> item; item.push_back(v); item.push_back(w); item.push_back(k); items.push_back(item); } vector<vector<int> > item_list; for(int i=0; i<n; i++){ for(int j=1; j<=items[i][2]; j++){ vector<int> item; item.push_back(items[i][0]); item.push_back(items[i][1]); item_list.push_back(item); } } vector<int> dp(s+1, 0); for(int i=0; i<item_list.size(); i++){ for(int j=s; j>=item_list[i][1]; j--){ dp[j] = max(dp[j], dp[j-item_list[i][1]]+item_list[i][0]); } } std::cout<<dp[s]<<endl; return 0; }

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

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