Please read the new rule regarding the restriction on the use of AI tools. ×

Negationist's blog

By Negationist, history, 23 hours ago, In English

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
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
12 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

my man k==2 case will get you to a nice n^2 TLE you must use binary search for each difference

  • »
    »
    56 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    The time complexity of n^2logn was correct if you look at the editorial

»
7 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

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