-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path51-Array.cpp
More file actions
41 lines (34 loc) · 831 Bytes
/
51-Array.cpp
File metadata and controls
41 lines (34 loc) · 831 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
//51-Array
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int n,x;
cin >> n;
vector <int> vec;
for (int i = 0; i < n; i++){
cin >> x;
vec.push_back(x);
}
sort(vec.begin(),vec.end());
if (vec.back() > 0)
{
cout << 1 << " " << vec.front() << "\n";
cout << 1 << " " << vec.back() << "\n";
cout << vec.size()-2 << " ";
for (int i = 1; i < vec.size() -1;i++)
cout << vec[i] <<" ";
cout << "\n";
}
else{
cout << 1 << " " << vec.front()<<"\n";
cout << 2 << " " << vec[1] << " " << vec[2] << "\n";
cout << vec.size()-3 << " ";
for (int i = 3; i < vec.size();i++)
cout << vec[i] << " ";
cout << "\n";
}
return 0;
}