Advertisement
Saleh127

CF 1419D1

Sep 19th, 2020 (edited)
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 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; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. ll a[200005],c,d,e,f,i,j,k,l;
  12. cin>>c;
  13.  
  14. for(i=0; i<c; i++)
  15. {
  16. cin>>a[i];
  17. }
  18.  
  19. sort(a,a+c,greater<int>());
  20. cout<<(c-1)/2<<endl;
  21. if(c%2==0)
  22. {
  23. for(i=0; i<(c/2); i++)
  24. {
  25. cout<<a[i]<<" "<<a[c-i-1]<<" ";
  26. }
  27. cout<<endl;
  28. }
  29.  
  30. else
  31. {
  32. for(i=0; i<(c/2); i++)
  33. {
  34. cout<<a[i]<<" "<<a[c-i-1]<<" ";
  35. }
  36. cout<<a[c/2]<<endl;
  37. }
  38. return 0;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement