Tell approach for it — "Find Index with minimum cost".

Правка en1, от rastogimudit02, 2025-04-07 21:02:37

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

Теги coding

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский rastogimudit02 2025-04-07 21:02:37 530 Initial revision (published)