jakaria_hossain

codeforce - Array

May 20th, 2019
69
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define pb push_back
  4. #define pp pop_back
  5. int main()
  6. {
  7. int n;
  8. scanf("%d",&n);
  9. int ara[n+1];
  10. for(int i=0;i<n;i++)scanf("%d",&ara[i]);
  11. vector<int>neg,pos,zer;
  12. for(int i=0;i<n;i++)
  13. {
  14. if(ara[i]==0)zer.pb(ara[i]);
  15. else if(ara[i]<0)neg.pb(ara[i]);
  16. else pos.pb(ara[i]);
  17. }
  18. if(neg.size()%2==0)
  19. {
  20.  
  21. zer.pb(neg[neg.size()-1]);
  22. neg.pp();
  23. }
  24. if(pos.size()==0)
  25. {
  26. pos.pb(neg[neg.size()-1]);
  27. neg.pp();
  28. pos.pb(neg[neg.size()-1]);
  29. neg.pp();
  30. }
  31. if(zer.size()==0)zer.pb(0);
  32. printf("%d",neg.size());
  33. for(int i=0;i<neg.size();i++)printf(" %d",neg[i]);
  34. printf("\n");
  35. printf("%d",pos.size());
  36. for(int i=0;i<pos.size();i++)printf(" %d",pos[i]);
  37. printf("\n");
  38. printf("%d",zer.size());
  39. for(int i=0;i<zer.size();i++)printf(" %d",zer[i]);
  40. printf("\n");
  41. }
RAW Paste Data