Блог пользователя Aafat_Wapas

Автор Aafat_Wapas, история, 5 лет назад, По-английски

Given an array of integers H representing heights of towers and a positive integer B. It is allowed to either increase or decrease the height of every tower by B (only once).

How to calculate the minimum possible difference between the heights of the longest and the shortest tower after modifications.

Note: It is mandatory to either increase or decrease the height of every tower.

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

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

Автор Aafat_Wapas, история, 5 лет назад, По-английски

How To Find the minimum value of the expression below:

SUM(|x - A[i]|*B[i]), i >= 0 and i < N, B[i] > 0

When B[i] = 1 I know the answer is given by x = Median(A).How to calculate x when B itself varies.

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

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