Can you please check this implementation

i tried to solve this question by pairwise sorting the elements combinations

this is my implementation please have a look

Hey @pradyumn25jain check this out


also don’t use
#ifndef ONLINE_JUDGE
freopen("…/input.txt", “r”, stdin);
freopen("…/output.txt", “w”, stdout);
#endif
when submitting codes online

yes i removed it and its working fine now , but why does the code not work with online judge ?

#ifndef ONLINE_JUDGE
freopen("…/input.txt", “r”, stdin);
freopen("…/output.txt", “w”, stdout);
#endif
these lines are meant for your compiler to decide for input and output files, hence should not be used with online judges as input.txt/output.txt may not be at online judge’s server!

alright thank you so much … got it