Wrong answer in SPOJ HORRIBLE

Everything seems fine to me,still am getting WA…Can someone help ?
My code :

Just change val from int to long long in update_tree function. You will get AC. Hope it helps !!

1 Like

Thanks for the help,but the constraint says that val <= 10^7…Then why do we need to change val from int to long long int ?

val is greater than 10^7 in test files most probably. Many SPOJ problems have such issues. Do check the comments on that problem because people generally put such issues there and make others aware.

oh thanks… will take care of it in future

v<=10^7 and size of array<=10^5.
So query will give result<=10^12(doesn’t fit in int).

//