I recently participated in Codeforces Round 895 (Div. 3) and encountered a Time Limit Exceeded (TLE) verdict for problem 1872F - Selling a Menagerie. Despite optimizing my code, I'm still puzzled by the TLE result.
I believe my code, with a time complexity of around O(10*n) which is near about o(n).
My code received a TLE verdict, which I find unexpected given its theoretical efficiency.
Could anyone please examine my code and share insights or optimizations.
Code Link: 222367949
Your assistance would be greatly appreciated.