-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1144C Two Shuffled Sequences.cpp
66 lines (65 loc) · 1.29 KB
/
1144C Two Shuffled Sequences.cpp
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
55
56
57
58
59
60
61
62
63
64
65
/*
author : MishkatIT
created : Tuesday 2022-12-20-21.29.16
problem : C. Two Shuffled Sequences
*/
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
fio;
int n;
cin >> n;
int temp;
map<int, int> mp;
bool ok = true;
for (int i = 0; i < n; i++)
{
cin >> temp;
mp[temp]++;
if(mp[temp] > 2)
{
ok = false;
}
}
if(ok)
{
vector<int> inc;
for (auto& i: mp)
{
if(i.second)
{
inc.push_back(i.first);
i.second--;
}
}
vector<int> dec;
for (auto i = mp.rbegin(); i != mp.rend(); i++)
{
if(i -> second)
{
dec.push_back(i -> first);
i -> second--;
}
}
cout << "YES" << '\n';
cout << inc.size() << '\n';
for(auto& i: inc)
{
cout << i << ' ';
}
cout << '\n';
cout << dec.size() << '\n';
for (auto& i: dec)
{
cout << i << ' ';
}
cout << '\n';
}
else
{
cout << "NO" << '\n';
}
return 0;
}