Submission #899192

# Submission time Handle Problem Language Result Execution time Memory
899192 2024-01-05T15:11:13 Z Blagoj Pod starim krovovima (COCI20_psk) C++17
40 / 50
1 ms 348 KB
#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
1 Partially correct 0 ms 344 KB Output is partially correct
2 Partially correct 1 ms 348 KB Output is partially correct
3 Partially correct 1 ms 348 KB Output is partially correct
4 Partially correct 0 ms 348 KB Output is partially correct
5 Partially correct 0 ms 348 KB Output is partially correct
6 Partially correct 0 ms 348 KB Output is partially correct
7 Partially correct 0 ms 348 KB Output is partially correct
8 Partially correct 1 ms 348 KB Output is partially correct
9 Partially correct 1 ms 348 KB Output is partially correct
10 Partially correct 1 ms 348 KB Output is partially correct