// Codeforces Round #181 (Div. 2) A Array
import java.io.*;
import java.math.*;
import java.util.*;
//Codeforces
public class MainCodeforces1 {
private static MyScanner in;
private static PrintStream out;
private static boolean LOCAL_TEST = false;
private static void solve() throws IOException
{
int n = in.nextInt();
ArrayList<Integer> zero = new ArrayList<>();
ArrayList<Integer> pos = new ArrayList<>();
ArrayList<Integer> neg = new ArrayList<>();
for (int i = 0; i < n; i++) {
int a = in.nextInt();
if (a == 0)
zero.add(0);
else if (a < 0)
neg.add(a);
else
pos.add(a);
}
out.println("1 " + neg.get(0));
if (pos.size() > 0) {
out.print(pos.size());
for (int i = 0; i < pos.size(); i++) {
out.print(" " + pos.get(i));
}
out.println();
out.print(zero.size() + neg.size() - 1);
for (int i = 0; i < zero.size(); i++) {
out.print(" 0");
}
for (int i = 1; i < neg.size(); i++) {
out.print(" " + neg.get(i));
}
out.println();
}
else {
out.print("2");
out.print(" " + neg.get(1));
out.print(" " + neg.get(2));
out.println();
out.print(zero.size() + neg.size() - 3);
for (int i = 0; i < zero.size(); i++) {
out.print(" 0");
}
for (int i = 3; i < neg.size(); i++) {
out.print(" " + neg.get(i));
}
out.println();
}
}
public static void main(String[] args) throws IOException {
// helpers for input/output
out = System.out;
try {
String cname = System.getenv("COMPUTERNAME");
LOCAL_TEST = (cname.equals("ALPHA530"));
} catch (Exception e) {
}
if (LOCAL_TEST) {
in = new MyScanner("E:\\zin.txt");
}
else {
boolean usingFileForIO = false;
if (usingFileForIO) {
// using input.txt and output.txt as I/O
in = new MyScanner("input.txt");
out = new PrintStream("output.txt");
}
else {
in = new MyScanner();
out = System.out;
}
}
solve();
}
// =====================================
static class MyScanner {
Scanner inp = null;
public MyScanner() throws IOException
{
inp = new Scanner(System.in);
}
public MyScanner(String inputFile) throws IOException {
inp = new Scanner(new FileInputStream(inputFile));
}
public int nextInt() throws IOException {
return inp.nextInt();
}
public long nextLong() throws IOException {
return inp.nextLong();
}
public double nextDouble() throws IOException {
return inp.nextDouble();
}
public String nextString() throws IOException {
return inp.next();
}
}
}
No comments:
Post a Comment