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

题解:我抄的,但是

a[i]<a[i+1]

这个为什么啊??? 做了一些测试,感觉可以证明。

/*
*@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 cnt,flag,temp,sum;
int a[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]);
    vector<int>v1={-1};
    vector<int>v2={INF};
    vector<int>ans;
    for(int i=1;i<=n;i++){
        u=v1.back()<a[i];
        v=v2.back()>a[i];
        if(u&&v){
            if(i+1<=n){
                if(a[i]<a[i+1]){
                    v1.push_back(a[i]);
                    ans.push_back(0);
                }else{
                    v2.push_back(a[i]);
                    ans.push_back(1);
                }
            }else{
                v1.push_back(a[i]);
                ans.push_back(0);
            }
        }else if(u||v){
            if(u){
                v1.push_back(a[i]);
                ans.push_back(0);
            }else{
                v2.push_back(a[i]);
                ans.push_back(1);
            }
        }else{
            flag=1;
            break;
        }
    }
    if(!flag){
        cout<<"YES"<<endl;
        for(int i:ans)cout<<i<<' ';
    }else{
        cout<<"NO"<<endl;
    }
    //}

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