fierce_adversary's blog

By fierce_adversary, history, 5 hours ago, In English

Hello everyone,Today, I was working on the CSES Stick Lengths problem, where the solution involves using the median as the optimal value for each element. This got me thinking: what if instead of the median, I used one of the following three values? Which type of deviation or cost would be minimized?

  1. Ceiling value of the mean
  2. Floor value of the mean
  3. Rounded value of the mean

I initially asked ChatGPT about it, but the explanation left me a bit confused. I’m curious to hear your insights on this. Thanks in advance!

  • Vote: I like it
  • +8
  • Vote: I do not like it

»
5 hours ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Choosing the mean of a set of values minimises the squared differences. The proof is already shown here, so I won't rewrite it. I think if the mean isn't a whole number and you have to choose an integer value, the rounded value would be optimal since it's closer to the local minimum and the curve is symmetric.

  • »
    »
    4 hours ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    Thanks bro, this was very helpful :)