atcoder#AGC059D. [AGC059D] Distinct Elements on Subsegments
[AGC059D] Distinct Elements on Subsegments
Score : points
Problem Statement
For an integer array (), let's construct an array , where is the number of distinct elements in .
You are given . Determine if there exists an array which could have produced such an array , and if yes, construct one.
Solve test cases for each input file.
Constraints
- The sum of in one input file doesn't exceed .
- The sum of in one input file doesn't exceed .
- All values in the input are integers.
Input
Input is given from Standard Input in the following format:
Each case is in the following format:
Output
For each test case, if such an array doesn't exist, output NO
.
Otherwise, output the answer in the following format:
YES
Here, must hold, and should produce . If multiple solutions exist, any of them will be accepted.
In printing YES
or NO
, you can output each letter in any case (upper or lower).
3
3 3
1 2 1
4 3
1 2 2 1
6 4
3 3 3 3 3 3
NO
YES
1 1 1 2 2 2
YES
1 2 3 1 2 3 1 2 3