C. 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 [x1<x2<⋯<xk][x1<x2<⋯<xk]. And strictly decreasing sequence is a sequence of integers [y1>y2>⋯>yl][y1>y2>⋯>yl]. 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 aaaaaa[1,3,4][1,3,4][10,4,2][10,4,2][1,2,3,4,4,10][1,2,3,4,4,10][4,2,1,10,4,3][4,2,1,10,4,3]

This shuffled sequence aa 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 aa to increasing and decreasing sequences, print "NO".

Input

The first line of the input contains one integer nn (1≤n≤2⋅1051≤n≤2⋅105) — the number of elements in aa.

The second line of the input contains nn integers a1,a2,…,ana1,a2,…,an (0≤ai≤2⋅1050≤ai≤2⋅105), where aiai is the ii-th element of aa.

Output

If there is a contradiction in the input and it is impossible to split the given sequence aa

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 nininini

In the third line print niniinc1,inc2,…,incniinc1,inc2,…,incniinc1<inc2<⋯<incniinc1<inc2<⋯<incnini=0ni=0

In the fourth line print ndnd — the number of elements in the strictly decreasing sequence. ndnd can be zero, in this case the decreasing sequence is empty.

In the fifth line print ndnddec1,dec2,…,decnddec1,dec2,…,decnddec1>dec2>⋯>decnddec1>dec2>⋯>decndnd=0nd=0

ni+ndni+ndn

代码:

 #include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int main() {
int zen[],b[],c[];
int n,zhi,count=,jishu2=;
cin>>n;
set<int> a,d;
for(int i=; i<n; i++) {
cin>>zhi;
if(a.count(zhi)) {
c[jishu2++]=zhi;
if(d.count(zhi)) {
cout<<"No";
return ;
}
d.insert(zhi);
}
a.insert(zhi);
b[i]=zhi;
}
for(set<int>::iterator it=a.begin(); it!=a.end(); it++) {
zen[count++]=*it;
}
sort(zen,zen+count,greater<int>());
sort(c,c+jishu2);
cout<<"Yes"<<endl;
cout<<jishu2<<endl;
for(int i=; i<jishu2; i++) {
cout<<c[i]<<" ";
}
cout<<endl;
cout<<count<<endl;
for(int i=; i<count; i++) {
cout<<zen[i]<<" ";
}
cout<<endl;
}

思路分析:先将所有数存集合中,然后将集合中数存到个数组中再对数组从大到小排序。然后便利,将集合中已存在元素存到新数组中作为递增序列。

题目链接:https://codeforces.com/contest/1144/problem/C

Codeforces1144C(C题)Two Shuffled Sequences的更多相关文章

  1. codeforces#FF DIV2C题DZY Loves Sequences(DP)

    题目地址:http://codeforces.com/contest/447/problem/C C. DZY Loves Sequences time limit per test 1 second ...

  2. CodeForces Round #550 Div.3

    http://codeforces.com/contest/1144 A. Diverse Strings A string is called diverse if it contains cons ...

  3. CF550 DIV3

    A - Diverse Strings CodeForces - 1144A A string is called diverse if it contains consecutive (adjace ...

  4. [UCSD白板题] Longest Common Subsequence of Three Sequences

    Problem Introduction In this problem, your goal is to compute the length of a longest common subsequ ...

  5. 【刷题】BZOJ 4059 [Cerc2012]Non-boring sequences

    Description 我们害怕把这道题题面搞得太无聊了,所以我们决定让这题超短.一个序列被称为是不无聊的,仅当它的每个连续子序列存在一个独一无二的数字,即每个子序列里至少存在一个数字只出现一次.给定 ...

  6. Bracket Sequences Concatenation Problem CodeForces - 990C(括号匹配水题)

    明确一下  一个字符串有x左括号不匹配  和 另一个字符串有x个右括号不匹配  这俩是一定能够匹配的 脑子有点迷 emm... 所以统计就好了  统计x个左括号的有几个,x个右括号的有几个 然后 乘一 ...

  7. 【atcoder】Two Sequences [arc092 D](思维题)

    题目传送门:https://arc092.contest.atcoder.jp/tasks/arc092_b 这场arc好难啊...这场感觉不像正常的arc...其实这道题还可以更早写出来的,但是蒟蒻 ...

  8. 第31题:LeetCode946. Validate Stack Sequences验证栈的序列

    题目 给定 pushed 和 popped 两个序列,只有当它们可能是在最初空栈上进行的推入 push 和弹出 pop 操作序列的结果时,返回 true:否则,返回 false . 示例 1: 输入: ...

  9. [LeetCode] Repeated DNA Sequences 求重复的DNA序列

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...

随机推荐

  1. 宝塔利用git+ webhooks 实现git更新远程同步Linux服务器

    参考: https://blog.csdn.net/alipea/article/details/83858177 https://www.bt.cn/bbs/thread-5348-1-1.html ...

  2. PHP--关于上传文件大小的问题

    参考:https://www.cnblogs.com/jianqingwang/p/5863960.html https://blog.csdn.net/u013168253/article/deta ...

  3. 第九次-DFA最小化,语法分析初步

    1.将DFA最小化:教材P65 第9题 2.构造以下文法相应的最小的DFA S→ 0A|1B A→ 1S|1 B→0S|0 3.自上而下语法分析,回溯产生的原因是什么? 4.P100 练习4,反复提取 ...

  4. MAC地址欺骗(原理及实验)

    MAC地址欺骗 MAC地址欺骗(或MAC地址盗用)通常用于突破基于MAC地址的局域网访问控制,例如在交换机上限定只转发源MAC地址修改为某个存在于访问列表中的MAC地址即可突破该访问限制,而且这种修改 ...

  5. java 8 Streams简介

    目录 简介 Functional Interface Function:一个参数一个返回值 BiFunction:接收两个参数,一个返回值 Supplier:无参的Function Consumer: ...

  6. 【Linux常见命令】alias命令

    alias命令用于查看和设置指令的别名. 用户可利用alias,自定指令的别名. 若仅输入alias,则可列出目前所有的别名设置. alias的效力仅及于该次登入的操作.若要每次登入是即自动设好别名, ...

  7. Python 3之bytes新特性

    转载: Python 3最重要的新特性大概要算是对文本和二进制数据作了更为清晰的区分. 文本总是Unicode,由str类型表示,二进制数据则由bytes类型表示. Python 3不会以任意隐式的方 ...

  8. CodeForces - 1047A

    A. Little C Loves 3 I time limit per test1 second memory limit per test256 megabytes inputstandard i ...

  9. Regex 正则表达式入门

    0,什么是正则表达式 正则表达式(Regular Expression简写为Regex),又称为规则表达式,它是一种强大的文本匹配模式,其用于在字符串中查找匹配符合特定规则的子串. 正则表达式是独立于 ...

  10. python-format方法记录

      今天写脚本,遇到了这种情况:需要上一个脚本的回参作为一个路径参数,我用的os.path.join()处理,因为这个路径参数在最后一位,但是没有考虑到如果路径参数在中间的话,这样的拼接就只能把后面的 ...