Submission #500255

#TimeUsernameProblemLanguageResultExecution timeMemory
500255MounirPod starim krovovima (COCI20_psk)C++14
50 / 50
2 ms204 KiB
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define sz(x) (int)x.size() #define pb push_back #define pii pair<int, int> #define chmin(x, v) x = min(x, v) #define chmax(x, v) x = max(x, v) #define x first #define y second #define int long long using namespace std; signed main(){ int nVals; cin >> nVals; int sum = 0; vector<pii> volumes; for (int iVal = 0; iVal < nVals; ++iVal){ int cur, maxi; cin >> cur >> maxi; sum += cur; volumes.pb({maxi, iVal}); } sort(all(volumes)); reverse(all(volumes)); int i = 0; vector<int> quantites(nVals, 0); while (i < nVals && sum > 0){ quantites[volumes[i].second] = min(volumes[i].first, sum); sum -= volumes[i++].first; } cout << nVals - i << endl; for (int quantite : quantites) cout << quantite << " "; cout << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...