제출 #978429

#제출 시각아이디문제언어결과실행 시간메모리
978429vjudge1Knapsack (NOI18_knapsack)C++17
0 / 100
0 ms348 KiB
#include<bits/stdc++.h> #define ll long long #define endl '\n' using namespace std; int main(){ ll s, n; cin>>s>>n; ll v[n], w[n], k[n]; vector<pair<ll, ll>> vp; for(ll i=0;i<n;i++){ cin>>v[i]>>w[i]>>k[i]; vp.push_back(make_pair(v[i], i)); } sort(vp.begin(), vp.end(), greater<>()); for(auto i: vp) cout<<"e "<<i.first<<" "<<i.second<<endl; ll we=0, sum=0; for(ll i=0;i<vp.size();i++){ ll ind = vp[i].second; while(we+w[ind]<=s && k[ind]!=0){ sum+=v[ind]; we+=w[ind]; k[ind]--; } } cout<<sum<<endl; return 0; }

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

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