SHARE
TWEET

A

a guest Apr 25th, 2013 1,014 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cstdio>
  2. #include <vector>
  3.  
  4. using namespace std;
  5. vector <int> first, second, third;
  6. int main () {
  7.         int n;
  8.         scanf("%d", &n);
  9.         for(int i = 0; i < n; i++) {
  10.                 int a;
  11.                 scanf("%d", &a);
  12.                 if (a == 0)
  13.                  third.push_back(a);
  14.                 if (a > 0)
  15.                         second.push_back(a);
  16.                 if (a < 0)
  17.                         first.push_back(a);
  18.         }
  19.         if (second.size() == 0) {
  20.                 for(int i = 0; i < 2; i++)
  21.                       second.push_back(first.back()), first.pop_back();
  22.         }
  23.         if (first.size() % 2 == 0) {
  24.                 third.push_back(first.back());
  25.                 first.pop_back();
  26.         }
  27.         printf("%d", first.size());
  28.         for(int i = 0; i < first.size(); i++) {
  29.                 printf(" %d",first[i]);
  30.         }
  31.         printf("\n%d", second.size());
  32.         for(int i = 0; i < second.size(); i++) {
  33.                 printf(" %d", second[i]);
  34.         }
  35.         printf("\n%d", third.size());
  36.         for(int i = 0; i < third.size(); i++) {
  37.                 printf(" %d", third[i]);
  38.         }
  39.         puts("");
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top