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

Автор rastogimudit02, история, 13 месяцев назад, По-английски

Find Index with minimum cost

There are n indices from 1 to n.

Some indices are marked and given as input in an array (size m).

For the unmarked indices, find the index having the minimum cost.

Cost of an index is defined as -

the sum of reciprocal of absolute difference between this index and all other marked index.

$$$COST(i) = \sum_{m_{idx} \in \text{marked indices}} \frac{1}{|i - m_{idx}|}$$$

Constraint: 1 <= n, m <= 1e5

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

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