Saleh127

CF 1407A

Sep 8th, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; while(t--)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. test
  12. {
  13. ll a[200000],c,d=0,e=0,f=0,i,j=0,k,l;
  14.  
  15. cin>>c;
  16.  
  17. for(i=1; i<=c; i++)
  18. {
  19. cin>>a[i];
  20. if(a[i]==1) e++;
  21. else f++;
  22. }
  23.  
  24. if(e>f)
  25. {
  26. if(e%2) e--;
  27. cout<<e<<endl;
  28. for(i=0;i<e;i++)
  29. {
  30. cout<<1<<" ";
  31. }
  32. }
  33. else
  34. {
  35. cout<<c/2<<endl;
  36. for(i=1;i<=c/2;i++)
  37. {
  38. cout<<0<< " ";
  39. }
  40. }
  41. cout<<endl;
  42. }
  43. return 0;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment