yswartz's blog

By yswartz, history, 9 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

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

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

»
9 years ago, hide # |
 
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

»
9 years ago, hide # |
 
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.