-
Notifications
You must be signed in to change notification settings - Fork 0
/
300A-Array.cpp
61 lines (51 loc) · 1.07 KB
/
300A-Array.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
// A. Array
// https://codeforces.com/problemset/problem/300/A
// Time 30 ms
// Memory 0 KB
// Rating 1100
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
int a[t];
vector<int> neg, pos, zero;
for (int i = 0; i < t; i++)
{
cin >> a[i];
if (a[i] > 0)
pos.push_back(a[i]);
else if (a[i] < 0)
neg.push_back(a[i]);
else
zero.push_back(a[i]);
}
if (pos.size() == 0)
{
pos.push_back(neg.back());
neg.pop_back();
pos.push_back(neg.back());
neg.pop_back();
}
if (neg.size() % 2 == 0)
{
zero.push_back(neg.back());
neg.pop_back();
}
cout << neg.size() << " ";
for (int x : neg)
cout << x << " ";
cout << "\n";
cout << pos.size() << " ";
for (int x : pos)
cout << x << " ";
cout << "\n";
cout << zero.size() << " ";
for (int x : zero)
cout << x << " ";
cout << "\n";
return 0;
}