# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
899192 | Blagoj | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 348 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;
#define endl '\n'
#define ll long long
#define all(x) (x).begin(), (x).end()
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<pair<ll, ll>> a(n);
ll sum = 0;
for (int i = 0; i < n; i++) {
ll x;
cin >> x >> a[i].first;
a[i].second = i;
sum += x;
}
sort(all(a));
reverse(all(a));
ll left = n;
ll ans[n];
memset(ans, 0, sizeof(ans));
for (int i = 0; i < n; i++) {
left--;
ans[a[i].second] = max(a[i].first, sum - a[i].first);
sum -= a[i].first;
if (sum <= 0) break;
}
cout << left << endl;
for (int i = 0; i < n; i++) cout << ans[i] << " ";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |