-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1144C.cpp
More file actions
54 lines (43 loc) · 790 Bytes
/
Copy path1144C.cpp
File metadata and controls
54 lines (43 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int n;
cin >> n;
vector<int>v(n);
for(int i=0;i<n;i++)
cin >> v[i];
sort(v.begin(),v.end());
int k=0;
for(int i=0;i<n-2;i++)
{
if(v[i] == v[i+1] and v[i] == v[i+2])
{
cout << "NO" << endl;
return 0;
}
}
vector<int>a,b;
for(int i=0;i<n-1;i++)
{
if(v[i]==v[i+1])
{
a.push_back(v[i]);
i++;
}
b.push_back(v[i]);
}
if(v[n-1]!=v[n-2])
b.push_back(v[n-1]);
cout << "YES" << endl << a.size() << endl;
for(int i=0;i<a.size();i++)
cout << a[i] << " ";
cout << endl << b.size() << endl;
for(int i=b.size()-1;i>=0;i--)
cout << b[i] << " ";
if(v[n-1]!=v[n-2])
b.push_back(v[n-1]);
cout << endl;
return 0;
}