# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
546739 | someone | Pod starim krovovima (COCI20_psk) | C++14 | 1 ms | 340 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 int long long
using namespace std;
struct Val {
int val, i, vol;
};
const int N = 1e5 + 42, INF = 1e18 + 42;
Val val[N];
int n, sum = 0, nb = 0;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 0; i < n; i++) {
cin >> val[i].val >> val[i].vol;
sum += val[i].val;
val[i].i = i;
}
sort(val, val + n,
[](Val a, Val b) {
return a.vol > b.vol;
});
for(int i = 0; i < n; i++) {
val[i].val = min(val[i].vol, sum);
sum -= val[i].val;
if(val[i].val == 0)
nb++;
}
sort(val, val + n,
[](Val a, Val b) {
return a.i < b.i;
});
cout << nb << '\n';
for(int i = 0; i < n; i++)
cout << val[i].val << ' ';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |