_Aragorn_'s blog

By _Aragorn_, history, 6 years ago, In English

Trying to solve 295A - Greg and Array using segment tree. Don't have any idea why I am getting WA on case 11.

Here is my code: 295A

  • Vote: I like it
  • +3
  • Vote: I do not like it

»
6 years ago, # |
Rev. 3   Vote: I like it +8 Vote: I do not like it

Next k lines contain the queries, the query number i is written as two integers: xi, yi, (1 ≤ xi ≤ yi ≤ m).

for(int i=1;i<=n+2;i++){ // change n + 2 to m
        flag[i] += flag[i-1];
}
for(ll i=1;i<=n;i++){ // change n to m
       update(1,1,n,l[i],r[i],(flag[i]*d[i]) );
}

Good luck, I hope it will help you :)