This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |