
One Saturday Luka woke up from an afternoon nap and remembered: today is COCI! There was only one thing that he needed to do before the contest: raise the blinds.
Luka has
- He can start lifting any singular blind manually.
With this method, it takes him
seconds to raise the blind by 1 centimeter. - He can press a button, which starts raising all blinds in parallel at the same speed.
The speed at which the blinds are raised with a button is defined as follows:
If all blinds are still rising, each will rise by 1 centimeter in
COCI is about to start, and Luka wants to raise his blinds as soon as possible.
Meanwhile, his brother Marin entered the room and asked him
They realized that there is not enough time to think about it before COCI. Fortunately, the problem has just appeared here as well! Help them solve it!
Note: Luka will always raise the blinds by an integer number of centimeters.
Input Specification
The first line contains integers
The second line contains
The third line contains an integer
The fourth line contains
Output Specification
In the first and only line, print
Constraints
Subtask | Points | Constraints |
---|---|---|
1 | 16 | |
2 | 26 | |
3 | 32 | |
4 | 36 | No additional constraints. |
Sample Input 1
3 2 5 1
2 2 4
3
2 0 1
Sample Output 1
4 14 9
Explanation for Sample 1
To have all blinds lowered by at most
If all blinds need to be fully raised, Luka can first raise the third blind by
Similarly, if the blinds need to be lowered by at most
Sample Input 2
2 3 4 0
3 1
3
3 2 0
Sample Output 2
0 3 10
Sample Input 3
4 3 10 3
2 4 5 6
3
4 3 0
Sample Output 3
9 18 47
Comments