#P6188. Optimal Purchase of School Supplies
Optimal Purchase of School Supplies
Optimal Purchase of School Supplies
Xiao Ming’s class has a total class budget of \(n\) yuan. They plan to collectively purchase three types of items with the following prices:
- Compass: \(7\) yuan each
- Pencil: \(4\) yuan each
- Notebook: \(3\) yuan each
Xiao Ming is responsible for ordering the items. Let \(a, b, c\) be the quantities ordered for compasses, pencils, and notebooks respectively. The ordering must obey the following conditions, in order of priority:
- The entire budget must be exactly spent: \(7a+4b+3c=n\).
- Among all solutions, the number of complete sets should be as large as possible; that is, the value of \(\min(a,b,c)\) must be maximized.
- If there are multiple solutions with the same \(\min(a,b,c)\), choose the one with the greatest total number of items \(a+b+c\).
If there exists a valid solution, it can be proved that the optimal solution is unique. If no valid scheme exists, output -1
.
inputFormat
The input consists of a single integer \(n\) (\(1 \le n \le 10^4\) is suggested though not strictly limited) representing the total class budget.
outputFormat
If a valid purchasing plan exists, output three space‐separated non-negative integers \(a\), \(b\), and \(c\) representing the quantities of compasses, pencils, and notebooks for the optimal solution. Otherwise, output -1
.
sample
42
3 3 3