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 <[email protected]>

> 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 segment trees +
>> Lazy propagation. Please help me figure out my mistake.
>> I am getting a WA
>>
>> Note:
>> invariant : l <= p <=q <= r
>>
>> l and r are the limits of that node
>> p and q is the query range.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
__________________________________________________

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to