I submited in the D problem a O(n^3) logic because of 4 seconds,but it took TLE. Here it is: http://mirror.codeforces.com/contest/552/submission/11650074
In the comments I saw a source similar to me: http://mirror.codeforces.com/contest/552/submission/11648192 that passed.
What is wrong with mine?
you have a problem with your REP. check it again :))
ohh my god you are right... I lost so many points for that thing?? But why rep is slow?
You have a lot of operations for REP.
But problem has an O(n2) solution.
If you do the math O(n ^ 3) will be arround 10^9 which is a lot (codeforces' servers allow arround 10^8 per second). And If you care about learning seek for something better.
Hint: check the given constrains and try to reduce your time complexity :D
O(n^3) passes here in Codeforces for this problem within the TL.