영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
Problem
In a class with N students, it is time for the obligatory task of giving a speech. Most students are very excited to give their speeches and can hardly wait for their turn. First, they must be divided into three groups. Everyone in group 1 will then present to group 2, group 2 to group 3, and group 3 to group 1.
One complication in this grouping is that the students have different ambition levels. Each student i requires to give their speech to at least A_i people. So, if student i ends up in group 1, group 2 must have at least A_i members for student i to be satisfied.
(그림은 원문 저장소에서 볼 수 있습니다)
Figure 1: The image corresponds to the first example.
Your task is to determine, given the students' ambition levels, if there is a way to divide the students into three groups so that everyone is satisfied, and if so, find a valid division.
Input
The first line contains an integer N (3 ≤ N ≤ 5 · 10^5), the number of students in the class.
The second line contains N integers A_i (1 ≤ A_i ≤ N), where A_i is the minimum number of students the i-th student wants to give a speech to.
Output
If there is no valid division, print a single line with the string “NO”.
If there is a valid division, first print a line with the string “YES”. Then, print a line with a string S consisting of the characters 1, 2, and 3. The character at position i in this string indicates which group student i belongs to. If there are multiple solutions, you can print any of them.
Scoring
Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group.
| Group | Points | Constraints |
|---|---|---|
| 1 | 14 | A_1 = A_2 = … = A_N |
| 2 | 16 | N ≤ 10 |
| 3 | 11 | A_i ≤ 3 |
| 4 | 23 | N ≤ 3000 |
| 5 | 36 | No additional constraints. |
예제
예제 1
10 1 3 1 3 3 2 4 1 5 2
YES 3313332121
예제 2
3 1 2 2
NO