-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Array.cpp
More file actions
73 lines (60 loc) · 1.37 KB
/
A_Array.cpp
File metadata and controls
73 lines (60 loc) · 1.37 KB
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
66
67
68
69
70
71
72
73
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstring>
using ll= long long;
using ull= unsigned long long;
using lld= long double;
#define GREETINGS_FROM_LOS_POCATOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main() {
GREETINGS_FROM_LOS_POCATOS
int n;
cin >> n;
vector<int> positive, negative, zero;
for(int i = 0; i < n; i++) {
int x;
cin >> x;
if(x > 0) {
positive.push_back(x);
} else if(x < 0) {
negative.push_back(x);
} else {
zero.push_back(x);
}
}
if(positive.empty()) {
for (size_t i = 0; i < 2; i++)
{
positive.push_back(negative.back());
negative.pop_back();
}
}
if (negative.size() % 2 == 0) {
zero.push_back(negative.back());
negative.pop_back();
}
cout << negative.size() << " ";
for (int x : negative) {
cout << x << " ";
}
cout << endl;
cout << positive.size() << " ";
for (int x : positive) {
cout << x << " ";
}
cout << endl;
cout << zero.size() << " ";
for (int x : zero) {
cout << x << " ";
}
cout << endl;
return 0;
}