답안 #844226

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844226 2023-09-05T11:39:18 Z vjudge1 Pod starim krovovima (COCI20_psk) C++17
40 / 50
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+37;



signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    vector<int> a(n), ind(n), ans(n);
    iota(ind.begin(), ind.end(), 0);
    int sum=0;

    for (int i=0; i<n; i++){
       int x; cin >> x; sum+=x;

       cin >> a[i];
    }

    sort(ind.begin(), ind.end(), [&](int i, int j){
        return a[i] > a[j];
    });

    int s=0;
    for(int i=0; i<n; i++){
        int v=min(sum, a[ind[i]]);
        if(v==0) s++;
        ans[ind[i]]=v;
        sum-=v;
    }

    cout<<s<<"\n";

   for(auto i: ans) cout<<i<<" ";
} 
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Incorrect 1 ms 344 KB Output isn't correct