I was doing this problem https://codeforces.net/contest/1822/problem/G1 recently, and I was comparing my code to the editorial implementation and I kept getting TLE again and again, trying to make the code more and more similar to the implementation given. The ultimate thing that allowed AC was changing the static array "a" to a vector of size n as in the implementation. Anyone know why the vector performs better? Because I thought static arrays were faster if anything.
My AC submission: https://codeforces.net/contest/1822/submission/280480288 My submission just before that (using static array a): https://codeforces.net/contest/1822/submission/280480106
(Just scroll down to the main function at the very bottom -- there is a bunch of template stuff above it not for the problem).
Thank you in advance for any help.