-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeforces300A.cpp
More file actions
35 lines (34 loc) · 832 Bytes
/
Codeforces300A.cpp
File metadata and controls
35 lines (34 loc) · 832 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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,i,j,k,l,z,pos=0,negi=0;
cin>>n;
int a[n+3];
for(i=0;i<n;i++) {
cin>>a[i];
if(a[i]>0) pos++;
else if(a[i]<0) negi++;
}
sort(a,a+n);
cout<<1<<" "<<a[0]<<endl;//set1
if(pos)
{
for(i=1;i<n;i++)
{
if(a[i]>0) {cout<<1<<" "<<a[i]<<endl; //set2
j=i-1;break;}
}
i++;
cout<<pos-1+negi-1+1<<" "<<0<<" ";//set3
for(; i<n;i++) cout<<a[i]<<" ";
for( ;j>0;j--) if(a[j]<0) cout<<a[j]<<" ";
cout<<endl;
}
else {
cout<<2<<" "<<a[1]<<" "<<a[2]<<endl;//set2
cout<<negi-3+1<<" "<<0<<" ";
for(i=3;i<n;i++) if(a[i]<0) cout<<a[i]<<" ";
cout<<endl;
}
}