AT_arc227_b [ARC227B] Know Your Place
Description
You are given a length- $ N $ sequence of non-negative integers $ A=(A_1,A_2,\ldots,A_N) $ .
Determine whether there exists a sequence $ B=(B_1,B_2,\ldots,B_N) $ that is a permutation of $ A $ that satisfies the following condition for every $ i=1,2,\ldots,N $ , and construct one such sequence if it exists.
- $ B_i $ is equal to the number of integers $ j $ satisfying $ 1 \le j < i $ and $ B_j < B_i $ .
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ A_1 $ $ A_2 $ $ \ldots $ $ A_N $
Output Format
If there is no sequence $ B $ satisfying the condition, output `No`.
If one exists, output `Yes` and a sequence $ B $ in the following format:
> Yes $ B_1 $ $ B_2 $ $ \ldots $ $ B_N $
If multiple sequences satisfy the condition, you may output any of them.
Explanation/Hint
### Sample Explanation 1
The output sequence is a permutation of $ A $ . For $ i=1,2,3,4 $ , the number of elements to the left of $ B_i $ that are smaller than $ B_i $ is $ 0,1,0,3 $ , respectively, which equals $ B_i $ .
### Sample Explanation 2
Since there is only one element smaller than the value $ 2 $ , no permutation satisfies the condition.
### Sample Explanation 3
The output sequence is a permutation of $ A $ . For $ i=1,2,\ldots,7 $ , the number of elements to the left of $ B_i $ that are smaller than $ B_i $ is $ 0,1,1,3,4,4,6 $ , respectively, which equals $ B_i $ .
### Constraints
- $ 1 \le N \le 5 \times 10^5 $
- $ 0 \le A_i < N $
- All input values are integers.