#P7107. 天选之人
天选之人
Description
Curious, Gnar wants to study, in the general case, how many people can end up with the most marks. He prepares rolled paper balls for each of the participants, for a total of paper balls, among which exactly are marked in advance. Then, after the paper balls are uniformly shuffled, each person draws paper balls.
A person has the most marks if and only if no one else has more marks than them. Please help Gnar determine whether it is possible that exactly people draw the most marks. Since Gnar likes to get to the bottom of things, if it is possible, you also need to construct how many marked and unmarked paper balls each person draws.
Formally, suppose the -th person draws marked paper balls and unmarked paper balls. Your construction must satisfy:
- , and .
- .
- There are exactly distinct indices such that .
Input Format
Input four integers , whose meanings are described above.
Output Format
Output YES or NO in the first line (case-insensitive, e.g., yEs / No are both accepted), indicating whether it is possible that exactly people draw the most marks.
If the first line is YES, then output lines, each containing , representing the numbers of marked and unmarked paper balls drawn by each person.
Since the answer may not be unique, this problem uses a Special Judge. Any construction that satisfies the requirements in the statement will be accepted.
3 3 5 2
YES
2 1
2 1
1 2
3 3 3 2
NO
3 3 5 3
NO
Hint
[Sample Explanation #1]
The sample provides one construction that satisfies the conditions.
[Sample Explanation #2]
No matter what, there are only three possible distributions of marks from high to low: , , . The corresponding numbers of people with the most marks are , , and . Therefore, it is impossible to construct a solution with .
[Constraints and Conventions]
This problem uses bundled testdata. You must pass all test points in a Subtask to receive the score for that Subtask.
- Subtask #1 (15 points): .
- Subtask #2 (15 points): .
- Subtask #3 (20 points): .
- Subtask #4 (10 points): .
- Subtask #5 (40 points): no special constraints.
For all testdata, it is guaranteed that , , .
Translated by ChatGPT 5
京公网安备 11011102002149号