help with TLE using python

Revision en1, by jcai972, 2022-03-02 18:56:13

Hi, I am timing out on this problem, and I do not know why. https://codeforces.net/problemset/problem/1638/B https://codeforces.net/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.

Tags tle, python3

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English jcai972 2022-03-02 19:12:19 53 Tiny change: 'n advance.' -> 'n advance.\n\nEDIT:\nI already got the answer thanks everyone. '
en1 English jcai972 2022-03-02 18:56:13 606 Initial revision (published)