# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
500255 | Mounir | Pod starim krovovima (COCI20_psk) | C++14 | 2 ms | 204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |