Блог пользователя Social-Verifier

Автор Social-Verifier, история, 2 года назад, По-английски

Given an Array of N elements and we want to make all elements in array equal we can do 2 following operations

  1. increase any element by 1
  2. decrease any element by 1

What is the minimum number of operation we can do to make all elements in array equal. ?

I tried this problem and found that making every element equal to the median of array is optimal is there any proof for this. ?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится