____noOne____'s blog

By ____noOne____, history, 7 years ago, In English

I am getting TLE in test case 11 in this 35599469 problem. Is there any way to increase every value of an array by some value without running any loop?

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

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by ____noOne____ (previous revision, new revision, compare).

»
7 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Take an extra variable say, bonus

For each type 2 update increase bonus by y

Then for each query on ith index it is  = a[i] + bonus

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I don't have time to see your submission, but you can use any range query data structure like BIT, or segment tree. But this problem is not that difficult, see the editorial.