skate1512's blog

By skate1512, history, 4 years ago, In English

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.

UPD: Solved.

Full text and comments »

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

By skate1512, history, 4 years ago, In English

The problem
I tried writing a generator script but that didn't help.
Submission Link.

Code explanation: In the problem, we are given an array/list and we have to check if we can form 1 square and 1 rectangle with those elements(planks). Only possible values are 8, 6 6, 6 2, 4 4, 4 2 2. I tried to count the numbers of 2s, 4s, 6s and 8s. And with every query, their value is incremented or decremented. In the end, I check if the values form any of the possible values and print Yes or No according to it. If anything is greater than 8 then I count it as 8.

Edit: I was missing 6 4 in my possible values. Accepted Solution.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it