#K60732. Minimum Moves to Restock Stores
Minimum Moves to Restock Stores
Minimum Moves to Restock Stores
You are given n stores, each with an initial number of items. Additionally, you are provided with a minimum required number of items x that each store must have and a maximum number of items k that can be added to a store in one move. Your task is to determine the minimum number of moves required for each store to reach at least x items.
For each store with current inventory i:
- If i \ge x, then no moves are required (output 0).
- If i < x and k > 0, then the minimum number of moves is given by \(\lceil (x-i)/k \rceil\).
- If i < x and k = 0, it is impossible to reach the required items; output -1.
Print the required moves for each store as a space-separated list.
inputFormat
The first line contains three integers: n (the number of stores), x (the minimum required items), and k (the maximum number of items that can be added per move). The second line contains n space-separated integers representing the initial inventory of each store.
outputFormat
Output a single line with n space-separated integers. The ith integer should be the minimum number of moves required for the ith store to have at least x items, or -1 if it is impossible.## sample
3 10 5
2 8 15
2 1 0
</p>