Here is the link to the problem: https://codeforces.com/problemset/problem/1363/D
Here is my solution: https://codeforces.com/contest/1363/submission/82189239
I have used a binary search to solve this problem as told in the Editorial. I found out the maximum value by giving a query of all the indices. Then I found the set containing that maximum value using Binary Search. After that, I found the second maximum value by querying for all the elements except the set containing the maximum value.
So, now the answer should be maximum for all the other sets and the second maximum for that use.
I am getting Idleness Limit Exceeded in test case 7 even after flushing the output and submitting 8 times.
If you can look at my code and let me know why something like this is happening, it would really help.