https://codeforces.com/contest/1144/problem/C

题意:给定一个序列,将它拆成两个序列,一个严格递增,一个严格递减。不能输出“No”。(一个数字的序列和空序列符合递增和递减要求

题解:正向一遍,逆向一遍

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=200000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int ans1,ans2,cnt,flag,temp,sum;
int a[N];
int b[N];
int c[N];
int vis[N];
char str;
struct node{};
int main()
{
#ifdef DEBUG
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    //scanf("%d",&t);
    //while(t--){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a+1,a+n+1);
    b[0]=-1;
    ans1=0;
    for(int i=1;i<=n;i++){
        if(b[ans1]<a[i]&&vis[i]==0){
            b[++ans1]=a[i];
            vis[i]=1;
        }
    }
    c[0]=INF;
    ans2=0;
    for(int i=n;i>=1;i--){
        if(c[ans2]>a[i]&&vis[i]==0){
            c[++ans2]=a[i];
            vis[i]=1;
        }
    }
    if(ans1+ans2!=n){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
        cout<<ans1<<endl;
        if(ans1==0)
            cout<<endl;
        for(int i=1;i<=ans1;i++){
            printf("%d%c",b[i]," \n"[i==ans1]);
        }
        cout<<ans2<<endl;
        if(ans2==0)
            cout<<endl;
        for(int i=1;i<=ans2;i++){
            printf("%d%c",c[i]," \n"[i==ans2]);
        }
    }
    //}

#ifdef DEBUG
	printf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif
    //cout << "Hello world!" << endl;
    return 0;
}