fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  4. /*bool is_prime(long int n)
  5. {
  6.   if (n == 1)
  7.   return false;
  8.   int i=2;
  9.   while (i*i <= n)
  10.   {
  11.   if (n % i == 0)
  12.   return false;
  13.   i += 1;
  14.   }
  15.   return true;
  16. }*/
  17. int main ()
  18. {
  19. FAST;
  20. //freopen("rev.in","r",stdin);
  21. int n , q;
  22. cin>>n>>q;
  23. vector<int>num(n);
  24. for(int I=0 ; I<n ; I++)
  25. cin>>num[I];
  26. sort(num.begin(),num.end());
  27. vector<int>temp(n);
  28. int I=0 ,j;
  29. for(; I<(0.5*n) ; I++)
  30. temp[(n-1)-I]=num[I];
  31. j=I;
  32. for(; I<n ; I++)
  33. temp[I-j]=num[I];
  34. for(int I=0 ; I<n ; I++)
  35. cout<<temp[I]<<" ";
  36. return 0;
  37. }
Success #stdin #stdout 0.01s 5360KB
stdin
3 3
5 3 2
stdout
5 3 2