jcai972's blog

By jcai972, history, 3 years ago, In English

Hi, I am timing out on this problem, and I do not know why. https://mirror.codeforces.com/problemset/problem/1638/B https://mirror.codeforces.com/contest/1638/submission/148130514 heres my submission to the problem. This should have a time complexity of O(n), but it times out on test case 5. I created 2 arrays, one for the even numbers and one for the odd numbers, and I checked if they were sorted. Is there any faster way to solve this problem, or am I doing something wrong? I'm submitting to PyPy 3 and I googled how to speed up I/O in python, but it still fails. Thanks in advance.

EDIT: I already got the answer thanks everyone.

  • Vote: I like it
  • +6
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it +2 Vote: I do not like it

Use fast io. (2nd line of the submission)