Distributed Contractor Allocation

A distributed platform has n contractors. Contractor i has a quality score quality[i] > 0 and a minimum expected wage wage[i] > 0. The platform must hire exactly k contractors.

Pay must be proportional to quality: if the hired set is S, the platform chooses a common rate r and pays contractor j in S an amount r * quality[j]. Fairness requires r * quality[j] >= wage[j] for every hired contractor, so r >= max_{j in S} wage[j] / quality[j]. The cheapest feasible rate for a fixed set is r = maxRatio(S), and the total cost for that set is r * sumQuality(S).

Choose k contractors to minimize total cost. To avoid unstable floating point equality, the answer is returned as a fixed-precision scaled integer: micro-units of cost.

Scaled return: answer = floor(minTotalCost * 1_000_000) computed with exact integer arithmetic as floor(sumQuality * wage[anchor] * 1_000_000 / quality[anchor]) where anchor is the contractor that defines maxRatio in the optimal set. All expected values in tests are this scaled integer. The optimization concept (ratio sorting plus max-heap on quality) is identical to the classic floating point formulation.

Examples
Input: [[10,20,5],[70,50,30],2]
Output: 105000000
Hints

Distributed Contractor Allocation

A distributed platform has `n` contractors. Contractor `i` has a quality score `quality[i] > 0` and a minimum expected wage `wage[i] > 0`. The platform must hire exactly `k` contractors.