Submission #1099595

# Submission time Handle Problem Language Result Execution time Memory
1099595 2024-10-11T19:24:37 Z Petrix Pod starim krovovima (COCI20_psk) C++17
40 / 50
1 ms 348 KB
#include <iostream>
#include <algorithm>
using namespace std;

int rasp[1001];
struct pahar{
    int a,ind;
} v[1001];

bool cmp(pahar a,pahar b){
    return a.a>b.a;
}

int main()
{
    int i,a,n,sum=0,cnt=0;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>a>>v[i].a;
        v[i].ind=i;sum+=a;
    }
    sort(v+1,v+n+1,cmp);
    for(i=1;i<=n;i++){
        if(sum){
            rasp[v[i].ind]=min(sum,v[i].a);
            sum-=min(sum,v[i].a);
        }else cnt++;
    }
    cout<<cnt<<"\n";
    for(i=1;i<=n;i++) cout<<rasp[i]<<" ";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Incorrect 1 ms 348 KB Output isn't correct