Why I get TLE in subtask 3 for the solution of UWCOI20B?

Can you guys please tell me why I get TLE for the final subtask of this UWCOI20B problem. My solution get AC for subtask 1 and 2.
Here is my submission link: https://www.codechef.com/viewsolution/29900081
Please help.

I don’t know much python but it seem a O(n^2) at line 7. A simpler solution would be just count odd number and even number and print (odd*even).

1 Like

Read editorial UWCOI20B - Button Pairs - Editorial


I don’t know much python,but here is my solution http://p.ip.fi/I-mq .
I also got TLE on my first attempt.

1 Like