cswork / OAOpen practice workspace

AmazonOA #73

Min Operations (Bring Price Range Below d)

Estimated HardStatement and editorial — judging is being prepared

Topics (AI-labelled)Binary SearchGreedy

Given prices[n], integers k and d. Each op picks two indices (x, y) and a p ≤ k, then prices[x] += p, prices[y] -= p. Make max - min < d with minimum ops.

Constraints

  • 1 ≤ n ≤ 10⁵
  • 1 ≤ prices[i] ≤ 10⁹
  • 1 ≤ k ≤ 10⁹
  • 2 ≤ d ≤ 10⁹

Editorial

Loading solution…