I submitted the same solution on two c++ compilers g++ 17 and g++ 20 . On g++ 20 my solution ran quite fast and got ac in 200ms . on the other hand on g++ 17 it got TLE with 2000ms runtime . I dont know whether the issue is with the time complexity of my solution or the compiler?
here is the link for the problem : https://codeforces.net/contest/1654/problem/C
here are my submissions: (AC) https://codeforces.net/contest/1654/submission/288743518
(TLE) https://codeforces.net/contest/1654/submission/288743107