LEALCO - Editorial

Are you kidding on me?
You have check() inside the loop of filling vector test.
So complexity is O(2^N * N * (N-K+1) * K) which of course is slow.
Simply moving one brace I get AC in 0.27 max time per test:
http://www.codechef.com/viewsolution/1727641
So don’t blame STL. Vector is the last thing you should blame.
Of course if you are using it wisely.

Codechef server is very fast.
It is Intel Pentium G860 3GHz.
Refer to this (it is Cube).
Tester first solution runs in 0.01 seconds on your test file.
While maximal time for your solution over our test data is 0.08.

Both the solution given are brute force solutions. What I do not understand is that is there no algorithmic approach to this question. I understand that these solution perform very well but am just curious about if there can be some algorithm for this.

Nice Question