ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1510. Order

For C++ Users
Posted by 0blivium 19 Oct 2018 16:29
I got TLE for both, straightforward sort-solution (n*logn) and Moore's algorithm (n).
You can avoid it using this line in your code:
- ios_base::sync_with_stdio(false);

Commands "cout" and "cin" are immensely slow and for large inputs, your code can get TLE.
Surprisingly, both approaches differ from each other only by 0.02 sec (with the aforementioned line included).