Problem Analysis:

If we observe correctly, we can see that there are some corner cases. Firstly, we need to keep in check the energy units. This energy can’t be negative. Secondly, the sum of the units of energy can overflow if we use integer data type to store the energy unit. So to solve these we do the following :-

  1. If the summation of energy unit is negative then we have to save it as 0 as his current energy units.

  2. We just need to use data type long long instead int, this will solve our integer overflow issue.

Statistics

20% Solution Ratio
Asif_AlimEarliest, 11M ago
TarequeFastest, 0.2s
tanvir4nLightest, 4.9 MB
user.8680Shortest, 507B
Toph uses cookies. By continuing you agree to our Cookie Policy.