Submission #968345

# Submission time Handle Problem Language Result Execution time Memory
968345 2024-04-23T10:29:52 Z maxFedorchuk Stranded Far From Home (BOI22_island) C++17
0 / 100
151 ms 18972 KB
#include <bits/stdc++.h>
using namespace std;

const long long MX=2e5+10;
long long s[MX],pr[MX];
int ans[MX];

long long get_sum(int l,int r)
{
    return pr[r]-pr[l-1];
}

bool cmp(int a,int b)
{
    return (s[a]>s[b]);
}

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

    int n,m;
    cin>>n>>m;

    for(int i=1;i<=n;i++)
    {
        cin>>s[i];
        pr[i]=pr[i-1]+s[i];
    }

    for(int i=1;i<=m;i++)
    {
        int a,b;
        cin>>a>>b;
    }

    vector < int > por;
    for(int i=1;i<=n;i++)
    {
        por.push_back(i);
    }
    sort(por.begin(),por.end(),cmp);

    set < int > zr;
    zr.insert(0);
    zr.insert(n+1);

    for(auto u:por)
    {
        auto it=zr.lower_bound(u);

        int rg=(*it);
        int lg=(*prev(it));

        long long sm=get_sum(lg+1,rg-1);

        if((ans[rg] && sm>s[rg]) || (ans[lg] && sm>s[lg]) || (rg-lg>n))
        {
            ans[u]=1;
        }

        zr.insert(u);
    }

    for(int i=1;i<=n;i++)
    {
        cout<<ans[i];
    }
    cout<<"\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 Incorrect 114 ms 18236 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 151 ms 18228 KB Output is correct
3 Incorrect 147 ms 18944 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 122 ms 18972 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 440 KB Output isn't correct
2 Halted 0 ms 0 KB -