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: CodeChef: Practical coding for everyone
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

2 Likes

I don’t know much python,but here is my solution pastebin .
I also got TLE on my first attempt.

1 Like