#K83327. Distinct Prize Distribution
Distinct Prize Distribution
Distinct Prize Distribution
You are given a total prize pool of $P$ dollars and $N$ winners. The goal is to distribute the prize money among the winners such that:
- Each winner receives an integer amount of dollars.
- No two winners receive the same amount. In other words, the distribution must consist of distinct positive integers.
- The distribution is in non-decreasing order.
The minimum amount of money required to give distinct prizes to N winners is the sum of the first N natural numbers, i.e., \[ S_{min} = \frac{N(N+1)}{2}. \]
If P is less than \(S_{min}\), it is impossible to distribute the prizes, and you should output -1
. Otherwise, start with the minimal distribution [1, 2, \dots, N]
and distribute the excess money starting from the largest prize while ensuring that all prizes remain distinct and in non-decreasing order.
Your task is to implement this logic.
inputFormat
The input consists of a single line containing two space-separated integers:
- P: total prize pool in dollars.
- N: number of winners.
For example: 15 5
outputFormat
If it is possible to distribute the prize money according to the conditions, output the allocated prize amounts in non-decreasing order, separated by a space. Otherwise, output -1
.
15 5
1 2 3 4 5
</p>