hello there. i've trying to solve a problem in uva but for some reason its always runtime, runtime, and runtime. i've check using the inputs given and they were right but when i submitted it: runtime! it's already my six-ed try anduva doesn't really give a reason why its a runtime so pls help me! i don't know what to do! >.<
What input data is used and what output do you get? Are there any error messages, if so please give the actual error message.
Edit: The key may be in attention to detail.
The two integers must be output in the same order as they were input. Also what happens if the two input integers are the same?
As for your code, the use of <vector> and <algorithm> here is overkill in my opinion, its more straightforward to simply keep track of the highest value of ctr instead of pushing it into the vector. I don't think type double is required as all values are integers here.
Don't know if this will help but here are some points:
If i == j on your first run, you have an empty vector and v.end() is returned. Since this points past the end of your vector, you'll likely to get a segmentation fault.
Calling vector::clear() doesn't guarantee reallocation or change in capacity, so if it's not your first run, and i == j, you may end up with the previous result rather than a crash. This is even worse.
Finally, consider that if your values are negative, then your inner while loop will never terminate!
o.k i've changed the code into a simpler form and now it's a "wrong answer". I don't think there's anything wrong with it (since i checked the inputs and outputs using a different code that got accepted).