Submission #202356

# Submission time Handle Problem Language Result Execution time Memory
202356 2020-02-15T18:34:38 Z EmmanuelAC Pod starim krovovima (COCI20_psk) C++14
50 / 50
8 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll  V[1001], 
    C[1001],
    S[1001];

int main(){
    int N; cin >> N;

    ll tv = 0;
    for(int i=0; i<N; i++){
        cin >> V[i] >> C[i];

        tv += V[i];
    }

    int sol = N;
    while(tv > 0){
        sol --;

        int ind = 0, mx = -1;
        for(int i=0; i<N; i++){
            if(C[i] > mx && S[i] == 0)
                mx = C[i], ind = i;
        }

        S[ind] = min(tv, C[ind]);
        tv -= S[ind];
    }

    cout << sol << "\n";
    for(int i=0; i<N; i++)
        cout << S[i] << " ";
    cout << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 248 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 248 KB Output is correct
8 Correct 8 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 7 ms 376 KB Output is correct