Блог пользователя VandanRogheliya

Автор VandanRogheliya, история, 6 лет назад, По-английски

Sorry for this noob question, I am new to competitive coding. I want to know what in my code is causing "time limit exceeded". Link to my code

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
6 лет назад, скрыть # |
← Rev. 3  
Проголосовать: нравится +1 Проголосовать: не нравится

Let me say, you are asking OS for two arrays of length $$$2000001$$$ in each test case, and you set the arrays' elements equal to 0, which is $$$O(n)$$$, in other words you are doing $$$2000001$$$ iterations for each test case, its just too much. You dont have to clear all the array, you just need to clear first $$$n+1$$$ elements.

Iv'e cleared that and submitted your solution, it works very fast.

»
6 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

The constraint in the statement is 2e5, yours is 2e6! Edit temp1 and temp2 size to 2e5 then your problem could be solved!