답안 #202356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
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";
}
# 결과 실행 시간 메모리 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