답안 #968350

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968350 2024-04-23T10:31:51 Z maxFedorchuk Stranded Far From Home (BOI22_island) C++17
15 / 100
177 ms 19212 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 1 ms 604 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 127 ms 18940 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 153 ms 18912 KB Output is correct
3 Correct 177 ms 19148 KB Output is correct
4 Correct 125 ms 19144 KB Output is correct
5 Correct 92 ms 16732 KB Output is correct
6 Correct 144 ms 19116 KB Output is correct
7 Correct 126 ms 19020 KB Output is correct
8 Correct 135 ms 19212 KB Output is correct
9 Correct 106 ms 18152 KB Output is correct
10 Correct 125 ms 18524 KB Output is correct
11 Correct 112 ms 16856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 111 ms 19052 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 1 ms 604 KB Output isn't correct
5 Halted 0 ms 0 KB -