# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
198716 | socho | Pod starim krovovima (COCI20_psk) | C++14 | 7 ms | 504 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"
using namespace std;
int main() {
long long n;
cin >> n;
long long sm = 0;
vector<pair<long long, long long> > gls;
for (long long i=0; i<n; i++) {
long long amount, cap;
cin >> amount >> cap;
gls.push_back(make_pair(cap, i));
sm += amount;
}
sort(gls.begin(), gls.end());
reverse(gls.begin(), gls.end());
long long take[n];
memset(take, 0, sizeof take);
long long zr = 0;
for (long long i=0; i<n; i++) {
long long ca = gls[i].first, at = gls[i].second;
long long ta = min(ca, sm);
sm -= ta;
take[at] = ta;
if (ta == 0) zr++;
}
cout << zr << endl;
for (long long i=0; i<n; i++) {
cout << take[i] << ' ';
}
cout << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |