I have changed the code to handle this test case. I have already handled this before but got the WA so thought of handling 2 missiles at the same altitude, now I know it is wrong after reading this from the problem statement "once you hit a target, the next target can only be among the ones that are flying at higher altitudes than the one you just hit.".brianfry713 wrote: #include <cstdlib>
input:AC output:Code: Select all
1 1 1 2 3
Code: Select all
Max hits: 3 1 2 3
But still it is a WA

Thanks for catching the #include <cstdlib> mistake, I removed that while pasting it here, I don't know why but the code works fine without it as well on my machine with C++11.