Submission #400881

# Submission time Handle Problem Language Result Execution time Memory
400881 2021-05-08T19:10:49 Z DavidDamian Pod starim krovovima (COCI20_psk) C++11
4 / 50
2 ms 332 KB
#include <iostream>
#include <algorithm>

using namespace std;

struct vaso
{
    int vol;
    int agua;
    int id;
};

bool porVolumen(vaso A, vaso B)
{
    if (A.vol < B.vol) return true;
    else {
        if (A.vol == B.vol) {
            if (A.agua < B.agua) return true;
            else return false;
        }
        else return false;
    }
}

bool porId(vaso A, vaso B)
{
    return A.id < B.id;
}

vaso A[100005];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> A[i].agua >> A[i].vol;
        A[i].id = i;
    }
    sort(A + 1, A + 1 + n, porVolumen);
    int j_max = n;
    while (j_max >= 1 && A[j_max].vol - A[j_max].agua == 0){
        j_max--;
    }
    cout << j_max << endl;
    for (int i = 1; i <= n; i++) {
        if (i >= j_max) {
            break;
        }
        while (A[i].agua > 0){
            int agua = min(A[j_max].vol - A[j_max].agua, A[i].agua);
            A[j_max].agua += agua;
            A[i].agua -= agua;
            if (A[j_max].vol - A[j_max].agua == 0) {
                j_max--;
            }
            if (i >= j_max) {
                break;
            }
        }
    }
    sort(A + 1, A + 1 + n, porId);
    int total = 0;
    for (int i = 1; i <= n; i++) {
        if (A[i].agua == 0) {
            total++;
        }
    }
    cout << total << endl;
    for (int i = 1; i <= n; i++) {
        cout << A[i].agua << " ";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Partially correct 1 ms 204 KB Output is partially correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Incorrect 1 ms 300 KB Output isn't correct
6 Incorrect 1 ms 308 KB Output isn't correct
7 Incorrect 1 ms 204 KB Output isn't correct
8 Incorrect 2 ms 332 KB Output isn't correct
9 Incorrect 2 ms 332 KB Output isn't correct
10 Incorrect 2 ms 332 KB Output isn't correct