In problem C of yesterday’s round, i’ve tried to optimize the soln as much as i can, and still i’m getting a TLE in test case 8. Can you please help me in resolving this issue!?
My submission : https://codeforces.com/contest/1474/submission/104902419
Problem Link : Problem - C - Codeforces
My approach :
I use a TreeMap, and for every step, i use max = map.getFirst() to get the maximum element. then i search whether (sum - max) is present in the map or not, if it is present then we go further, otherwise we’ll return.
Similar solutions, in C++, are getting accepted. ( they use multiset) however, i’m having trouble with this. Please help!!!