Hi!! As apparent from the Title, I am getting TLE on test 21 for the question and I have no idea how to optimize it.(I read the tutorial but could not understand)
Question Link -> https://codeforces.net/contest/1848/problem/C
Submission Link -> https://codeforces.net/contest/1848/submission/278910279
I am pretty sure that there has to be some way to optimize the ans() function in my code. Can anyone help??
Thanks!!