# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
978429 | 2024-05-09T08:15:50 Z | vjudge1 | Knapsack (NOI18_knapsack) | C++17 | 0 ms | 348 KB |
#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; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |