Can someone tell me what is wrong in this
[1]
[1]: https://www.codechef.com/viewsolution/13896462
Can someone tell me what is wrong in this
[1]
[1]: https://www.codechef.com/viewsolution/13896462
It is just integer overflow. As n ≤ 105 and h ≤ 109, in the worst case sum would have to hold the value 105 × 109 = 1014, which does not fit in int type. Use long instead for sum. Also max*max overflows, which can be fixed by either using long for max too, or changing max*max to (long)max*max.
Thank you…
Sure thing 