Problem: Array Game — https://mirror.codeforces.com/contest/1904/problem/C Idea of the code, consider all possible combinations of 2 elements to make diff, mn = min of, mn, diff, [first element greater than diff]-diff, [one element left of the first element greater than diff]-diff. Thanks so much.
My Code
my man
k==2
case will get you to a nicen^2
TLE you must use binary search for each differenceThe time complexity of n^2logn was correct if you look at the editorial
at k==2 for(int i=0; i<n-1;i++) You put i<n-2, so you skipped one check
Try a=[5,98,99], ans is 1, but you get 4 because 98-(99-5)=4