amcbn

Halfsort

Nov 9th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. /* [A][M][C][B][N] / [K][R][I][P][6][8] */
  2. #include <bits/stdc++.h>
  3. #pragma warning(disable : 4996 4267 4068)
  4. using namespace std;
  5. template<typename type>
  6. using matrix = vector<vector<type>>;
  7. typedef long long ll;
  8. const char sp = ' ', nl = '\n';
  9. const int MOD = 1000000007;
  10.  
  11. int main() {
  12.     ios::sync_with_stdio(NULL);
  13.     cin.tie(nullptr), cout.tie(nullptr);
  14.     (void)!freopen("halfsort.in", "r", stdin);
  15.     (void)!freopen("halfsort.out", "w", stdout);
  16.     int n;
  17.     cin >> n;
  18.     vector<int> v(n);
  19.     for (int i = 0; i < n; ++i)
  20.         cin >> v[i];
  21.     sort(v.begin(), v.begin() + n / 2);
  22.     sort(v.begin() + n / 2, v.end(), greater<int>());
  23.     for (int i = 0; i < n; ++i)
  24.         cout << v[i] << sp;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment