Submission #580987

# Submission time Handle Problem Language Result Execution time Memory
580987 2022-06-22T07:39:36 Z AGE Pod starim krovovima (COCI20_psk) C++14
0 / 50
2 ms 468 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define pb push_back

using namespace std;
const int N=1e6,M=2e3,mod=1e9+7;
pair<int,pair<int,int> > a[N];
int anss[N];
main()
{

    int n;
    cin>>n;

    for(int i=0;i<n;i++){
        cin>>a[i].S.F>>a[i].F;
        a[i].S.S=i;
    }

    sort(a,a+n);
    int ans=0;

    for(int i=1;i<=n;i++){

        int emptyy=0;
        for(int j=0;j<i;j++){
            emptyy+=a[j].S.F;
        }
        int x=0;
        for(int j=i;j<n;j++)
            x+=a[j].F-a[j].S.F;

        if(x>=emptyy)
            ans=i;

    }

    int xx=0;
    for(int i=0;i<ans;i++)
        xx+=a[i].S.F;

    for(int i=0;i<ans;i++){
        anss[a[i].S.S]=0;
    }

    for(int i=ans;i<n;i++){

        int xxx=min(a[i].F-a[i].S.F,xx);
        xx-=xxx;
        anss[a[i].S.S]=a[i].S.F+xxx;

    }

    for(int i=0;i<n;i++)
        cout<<anss[i]<<" ";
    cout<<endl;
    return 0;
}

Compilation message

psk.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 308 KB Integer 70 violates the range [0, 9]
2 Incorrect 1 ms 212 KB Integer 9 violates the range [0, 8]
3 Incorrect 1 ms 212 KB Output isn't correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Incorrect 1 ms 212 KB Integer 61 violates the range [0, 20]
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Incorrect 2 ms 340 KB Output isn't correct
9 Incorrect 2 ms 468 KB Output isn't correct
10 Incorrect 2 ms 320 KB Output isn't correct