Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

TRY_TO_BE8T_ME's blog

By TRY_TO_BE8T_ME, history, 7 years ago, In English

Hello,

I have a query which i faced in Round #570 question D. In that I had used vector of defined size (vector a(n))firstly but it gave me TLE and then after changing the vector to simple array (long long int a[n]) then it passed all the test with the same logic and code just with this change in the code (vector to simple array).

So I want to know why did use of vector gave me TLE?

Thanks in advance.

  • Vote: I like it
  • -19
  • Vote: I do not like it

| Write comment?
»
7 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Declaring it in while loop means that the vector of 2*10^5 is created every time for each test case. For 10^5 cases doing it every time means complexity of ~10^10 and hence the time limit.