[algogeeks] Re: Horrible Queries on spoj

2013-02-27 Thread emmy
I saw other solutions which were accepted with long long int. So apart from the constraints is the algorithm correct? On Tuesday, February 26, 2013 12:24:44 PM UTC+5:30, emmy wrote: Problem statement http://www.spoj.com/problems/HORRIBLE/ Here http://ideone.com/NhDuYo is my code. I am using

Re: [algogeeks] Re: Horrible Queries on spoj

2013-02-27 Thread tec
Overflow can happen in intermediate calculations. For example: sums[i]+=(q-p+1)*v; q,p,v are of type long int, so the multiplication is performed in long int, then convert the result to long long int and added to sum[i]. 2013/2/27 emmy foramlakh...@gmail.com I saw other solutions which were

[algogeeks] Re: Horrible Queries on spoj

2013-02-27 Thread emmy
Thank you very much! that helped. On Tuesday, February 26, 2013 12:24:44 PM UTC+5:30, emmy wrote: Problem statement http://www.spoj.com/problems/HORRIBLE/ Here http://ideone.com/NhDuYo is my code. I am using segment trees + Lazy propagation. Please help me figure out my mistake. I am

[algogeeks] Re: Horrible Queries on spoj

2013-02-26 Thread emmy
please help On Tuesday, February 26, 2013 12:24:44 PM UTC+5:30, emmy wrote: Problem statement http://www.spoj.com/problems/HORRIBLE/ Here http://ideone.com/NhDuYo is my code. I am using segment trees + Lazy propagation. Please help me figure out my mistake. I am getting a WA Note:

Re: [algogeeks] Re: Horrible Queries on spoj

2013-02-26 Thread tec
One possible issue is overflow. Noting that each number can be as large as 1*10^7, and the total sum can reach 10^17. 2013/2/27 emmy foramlakh...@gmail.com please help On Tuesday, February 26, 2013 12:24:44 PM UTC+5:30, emmy wrote: Problem statement