#GD0000156. Hai dãy bị xáo trộn (Two Shuffled Sequences)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Hai dãy bị xáo trộn (Two Shuffled Sequences)
Two Shuffled Sequences
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Two integer sequences existed before their elements were merged and shuffled: the first was strictly increasing and the second strictly decreasing. Empty or single-element sequences are allowed. Given the shuffled sequence of integers, recover any two sequences with exactly the same combined multiset of values, or report that it is impossible.
Input
The first line contains . The second line contains exactly integers .
Output
Print NO if impossible. Otherwise print YES, then the length and elements of the strictly increasing sequence, followed by the length and elements of the strictly decreasing sequence. The elements of an empty sequence may be represented by a blank line.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
7
7 2 7 3 3 1 4
Output
YES
5
1 2 3 4 7
2
7 3
Explanation
The values and appear twice; each appear once. The increasing sequence takes one of each value, and takes the remaining copies. Both orders are strict and together contain the seven original values.