AREA UNDER HISTOGRAM STACk

https://ide.codingblocks.com/s/419118 ,
please check my code is not working , but sample output is same.

Modified Code

i have done required changes
use long long instead of int and also in the last while loop use i instead of n

but why long long int, there is not any constraint like this??

yes
Height of each bar in histogram <= 10^9
now if you multiply it with some no it will overflow the int

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.