欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1144C.Two Shuffled Sequences
Two Shuffled Sequences
Two integer sequences existed initially — one of them was strictly increasing, and the other one — strictly decreasing.
Strictly increasing sequence is a sequence of integers . And strictly decreasing sequence is a sequence of integers . Note that the empty sequence and the sequence consisting of one element can be considered as increasing or decreasing.
They were merged into one sequence . After that sequence got shuffled. For example, some of the possible resulting sequences for an increasing sequence and a decreasing sequence are sequences or .
This shuffled sequence is given in the input.
Your task is to find any two suitable initial sequences. One of them should be strictly increasing and the other one — strictly decreasing. Note that the empty sequence and the sequence consisting of one element can be considered as increasing or decreasing.
If there is a contradiction in the input and it is impossible to split the given sequence to increasing and decreasing sequences, print "NO".
Input
The first line of the input contains one integer () — the number of elements in .
The second line of the input contains integers (), where is the -th element of .
Output
If there is a contradiction in the input and it is impossible to split the given sequence to increasing and decreasing sequences, print "NO" in the first line.
Otherwise print "YES" in the first line and any two suitable sequences. Note that the empty sequence and the sequence consisting of one element can be considered as increasing or decreasing.
In the second line print — the number of elements in the strictly increasing sequence. can be zero, in this case the increasing sequence is empty.
In the third line print integers in the increasing order of its values () — the strictly increasing sequence itself. You can keep this line empty if (or just print the empty line).
In the fourth line print — the number of elements in the strictly decreasing sequence. can be zero, in this case the decreasing sequence is empty.
In the fifth line print integers in the decreasing order of its values () — the strictly decreasing sequence itself. You can keep this line empty if (or just print the empty line).
should be equal to and the union of printed sequences should be a permutation of the given sequence (in case of "YES" answer).
Samples
7
7 2 7 3 3 1 4
YES
2
3 7
5
7 4 3 2 1
5
4 3 1 5 3
YES
1
3
4
5 4 3 1
5
1 1 2 1 2
NO
5
0 1 2 3 4
YES
0
5
4 3 2 1 0
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |