Submission #170861

# Submission time Handle Problem Language Result Execution time Memory
170861 2019-12-26T15:37:32 Z juggernaut Weighting stones (IZhO11_stones) C++14
100 / 100
71 ms 7672 KB
//Just try and the idea will come!
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int mx[400001],mn[400001],add[400001],n,x,y,i;
void push(int v,int l,int r){
    if(l!=r){
        add[v*2]+=add[v];
        add[v*2+1]+=add[v];
    }
    mx[v]+=add[v];
    mn[v]+=add[v];
    add[v]=0;
}
void update(int v,int l,int r,int ql,int qr,int val){
    push(v,l,r);
    if(r<ql||qr<l)return;
    if(ql<=l&&r<=qr){
        add[v]+=val;
        push(v,l,r);
        return;
    }
    int mid=(l+r)>>1;
    update(v*2,l,mid,ql,qr,val);
    update(v*2+1,mid+1,r,ql,qr,val);
    mx[v]=max(mx[v*2],mx[v*2+1]);
    mn[v]=min(mn[v*2],mn[v*2+1]);
}
main(){
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%lld%lld",&x,&y);
        update(1,1,n,1,x,3-y*2);
        if(mx[1]>=0&&mn[1]>=0)puts(">");
        else if(mx[1]<=0&&mn[1]<=0)puts("<");
        else puts("?");
    }
}

Compilation message

stones.cpp:29:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
stones.cpp: In function 'int main()':
stones.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
stones.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld",&x,&y);
         ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 404 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 7 ms 1144 KB Output is correct
11 Correct 40 ms 3932 KB Output is correct
12 Correct 71 ms 7448 KB Output is correct
13 Correct 63 ms 7616 KB Output is correct
14 Correct 63 ms 7672 KB Output is correct
15 Correct 64 ms 7480 KB Output is correct
16 Correct 64 ms 7420 KB Output is correct
17 Correct 63 ms 7416 KB Output is correct
18 Correct 64 ms 7424 KB Output is correct
19 Correct 65 ms 7544 KB Output is correct
20 Correct 63 ms 7528 KB Output is correct
21 Correct 64 ms 7416 KB Output is correct
22 Correct 64 ms 7544 KB Output is correct
23 Correct 63 ms 7516 KB Output is correct
24 Correct 64 ms 7544 KB Output is correct
25 Correct 63 ms 7516 KB Output is correct