제출 #1046583

#제출 시각아이디문제언어결과실행 시간메모리
1046583NewtonabcKnapsack (NOI18_knapsack)C++14
73 / 100
1066 ms18828 KiB
#include<bits/stdc++.h> using namespace std; const int N=2e3+10; vector<pair<long long,long long> > v; int dp[N]; int main(){ int s,n; cin>>s >>n; while(n--){ long long a,b,c; cin>>a >>b >>c; long long tmp=1; while(c>=tmp){ v.push_back(make_pair(a*tmp,b*tmp)); c-=tmp; tmp*=2; } v.push_back(make_pair(a*c,b*c)); } for(int i=0;i<v.size();i++){ long long val=v[i].first,wg=v[i].second; for(int j=s;j>=1;j--){ if(j-wg>=0) dp[j]=max(dp[j],dp[j-(int)wg]+(int)val); } } cout<<dp[s]; }

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

knapsack.cpp: In function 'int main()':
knapsack.cpp:20:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  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...