# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
90551 | Bodo171 | Weighting stones (IZhO11_stones) | C++14 | 39 ms | 15640 KiB |
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 <iostream>
#include <fstream>
using namespace std;
const int nmax=100005;
struct node
{
int sum,minsuf,maxsuf;
}arb[4*nmax];
string ans;
int n,poz,wh,i,val;
void update(int nod,int l,int r)
{
if(l==r)
{
arb[nod].sum=arb[nod].maxsuf=arb[nod].minsuf=val;
return;
}
int m=(l+r)/2;
if(poz<=m) update(2*nod,l,m);
else update(2*nod+1,m+1,r);
arb[nod].maxsuf=max(arb[2*nod+1].maxsuf,arb[2*nod+1].sum+arb[2*nod].maxsuf);
arb[nod].minsuf=min(arb[2*nod+1].minsuf,arb[2*nod+1].sum+arb[2*nod].minsuf);
arb[nod].sum=arb[2*nod].sum+arb[2*nod+1].sum;
}
int main()
{
//freopen("data.in","r",stdin);
ios_base::sync_with_stdio(false);
cin>>n;
for(i=1;i<=n;i++)
{
cin>>poz>>wh;
if(wh==1) val=1;
else val=-1;
update(1,1,n);
if(arb[1].minsuf>=0&&arb[1].maxsuf>0) ans+=">\n";
else
{
if(arb[1].maxsuf<=0) ans+="<\n";
else ans+="?\n";
}
}
cout<<ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |