Help with CSES problemset

Правка en2, от skate1512, 2020-10-23 11:23:19

I can't solve this problem using python. I tried many variations of my code but all of them give TLE for 2 test cases. In C++, this problem can be solved using multiset, I tried using dict, collections.Counter, list in python but all of them give TLE. I used stdin and stdout to read the input and output. The time limit is 1 sec and 2 test cases with n = 2⋅10^5, m = 2⋅10^5 pass while the other two don't. I tried searching for solutions but the solutions provided also gave TLE in both cpython and pypy.

If two test cases with n = 2⋅10^5, m = 2⋅10^5 pass with time 0.2 sec maximum then how slow is my solution for the other test cases with similar values?

These two codes gave the best and similar results. First, Second.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский skate1512 2020-10-26 06:44:28 16 Tiny change: 'G6yDBhkd). ' -> 'G6yDBhkd).\n\nUPD: Solved. '
en2 Английский skate1512 2020-10-23 11:23:19 155
en1 Английский skate1512 2020-10-23 11:13:12 707 Initial revision (published)