I am very unhappy with getting TLE in recent contests for submissions that were of the exact same complexity as the editorial I saw afterwards :
Happened in D problem of the latest Div3. My nlog(n) submission didn't pass(TLE).
Again happened in C problem of Divide by zero contest. My O(n) solution didn't pass (TLE).
Again happened today problem B (last div2) My optimal solution didn't pass (TLE) (Editorial isn't out yet, but I wasn't expecting TLE at all)
Do I mess up everytime or is CF behaving unfair with me ?
{}
with0
which now gives runtime error 112878381That's because of undefined behaviour. You sometimes erase an element which doesn't exist, which can in some cases lead to TLE. AC code: 112879774
I removed 1 instance of
//
from your code and now it doesn't TLE. 112879724You get an infinite loop on the input
1
9 9 9
In conclusion, you mess up every time.
Now, when I take care of the element I was deleting twice, I get a WA. Please have a look — submission
I've thought multiple times over and can't find anything wrong now atleast.
s.erase(a[n - 2]);
should be replaced bys.erase(s.find(a[n - 2]));
Unless you see 1000's of people complaining about a strange bug, its most likely you who is messing up.
In 2nd problem use int instead of long long, I also got TLE with long long, but int got AC. TLE: 112759305 AC: 112759480