QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#20716. Better Dice

Statistics

You have a fair six-sided die with positive integer face values $a_1,a_2,\ldots,a_6$. Construct another fair six-sided die with positive integer face values $b_1,b_2,\ldots,b_6$ whose sum is exactly $k$. Face values may repeat on either die.

Roll each die once, independently. The new die wins if and only if its value is strictly greater than the original die's value; a tie is not a win. Determine whether you can make it win at least $19$ of the $36$ equally likely pairs of faces (that is, with probability strictly greater than $50\%$). If so, construct such a die.

Input

The first line contains six integers $a_1,a_2,\ldots,a_6$ ($1\le a_i\le 10^9$), the labels of the original die.

The second line contains an integer $k$ ($1\le k\le 10^{18}$), the required sum of the new die's labels.

Output

If no valid new die exists, print NO.

Otherwise, print YES on the first line and six positive integers $b_1,b_2,\ldots,b_6$ on the second line. Their sum must be exactly $k$, and the new die must win at least $19$ of the $36$ pairs of faces.

The labels may appear in any order. If multiple answers exist, print any one. The strings YES and NO are case-sensitive.

Examples

Input 1

1 2 3 4 5 6
25

Output 1

YES
1 1 2 7 7 7

Input 2

1 1 1 1 1 1
9

Output 2

NO

Note

For the first example, another valid choice of labels is $5,4,4,4,4,4$. These labels sum to $5+4+4+4+4+4=25$. Its face labeled $5$ beats four faces of the original die, and each face labeled $4$ beats three. Thus, it wins $4+5\cdot3=19$ pairs.

In the second example, a face must be labeled at least $2$ to win. Each such face wins six pairs, so at least four are needed to win $19$ pairs. Even if the other two faces are labeled $1$, the sum is at least $2+2+2+2+1+1=10>9$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.