Submission #90551

# Submission time Handle Problem Language Result Execution time Memory
90551 2018-12-22T11:32:28 Z Bodo171 Weighting stones (IZhO11_stones) C++14
100 / 100
39 ms 15640 KB
#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
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 588 KB Output is correct
3 Correct 2 ms 588 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 2 ms 588 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 5 ms 1244 KB Output is correct
11 Correct 23 ms 3112 KB Output is correct
12 Correct 39 ms 5492 KB Output is correct
13 Correct 34 ms 6316 KB Output is correct
14 Correct 33 ms 7088 KB Output is correct
15 Correct 33 ms 7860 KB Output is correct
16 Correct 33 ms 8592 KB Output is correct
17 Correct 32 ms 9436 KB Output is correct
18 Correct 33 ms 10236 KB Output is correct
19 Correct 32 ms 10972 KB Output is correct
20 Correct 33 ms 11780 KB Output is correct
21 Correct 33 ms 12552 KB Output is correct
22 Correct 37 ms 13356 KB Output is correct
23 Correct 32 ms 14096 KB Output is correct
24 Correct 34 ms 14864 KB Output is correct
25 Correct 32 ms 15640 KB Output is correct