We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Integer overflow. Even long long would not be enough to hold values for 'energy' with your current logic so it overflows and becomes negative. Because of this "while" stops too early (as energy is not >= 0). If you won't come up with idea how to overcome that, feel free to ask for clue.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Chief Hopper
You are viewing a single comment's thread. Return to all comments →
Integer overflow. Even long long would not be enough to hold values for 'energy' with your current logic so it overflows and becomes negative. Because of this "while" stops too early (as energy is not >= 0). If you won't come up with idea how to overcome that, feel free to ask for clue.