Олимпиадный тренинг

Задача 34832. Wage


Задача

Темы:
A certain company employs three employees — Alexey, Victor and Sergey. Their monthly salary is A, B and C rubles, respectively. At the same time, Aleksey works full-time, and Viktor and Sergey — half the rate, that is, they work half as much as Alexei.

At the end of the month, the director of the company wants to distribute the bonus fund, which amounts to N rubles, among these employees. At the same time, the director wants to distribute the bonus fund in such a way that the final salary (sum of salary and bonuses) for these employees is proportional to the time spent at work, that is, Alexey’s salary should be exactly twice as much as the salary of Viktor and Sergey. More formally, if Aleksey's premium is x rubles, Viktor's premium — y rubles, Sergey's award — z rubles, then A + x = 2 (B + y) = 2 (C + z), x + y + z ≤ N. At the same time, the accounting department requires that the size of the bonus (as well as the salary) be expressed in an integer number of rubles, and the director wants to distribute the largest possible part of the bonus fund, that is, the sum x + y + z should be the maximum possible, without exceeding N.

Write a program that will determine what bonus to give to each employee.
The program first receives as input three integers A, B, C, written in separate lines, — salaries of Alexey, Viktor and Sergey (A > 0, B > 0, C > 0). The fourth line of the input contains one integer N — the size of the bonus fund (N ≥ 0).
The program should output three numbers — the amount of the prize for Alexey, Victor and Sergey. If the bonus pool cannot be distributed in such a way that the required conditions are met, the program should print a single number 0.
 
Input Output Note
7
3
4
12
5
3
2
Taking into account the bonus, Alexey's salary will be 12 rubles, Victor and Sergey — 6 rubles.
20
10
11
2
0 It is impossible to achieve the desired ratio of bonus payments.