@LevMckinney/

tides sulotion

C++

No description

fork
loading
Files
  • main.cpp
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
  int n = 0;
  std::cin >> n;
  std::vector<int> Data(n, 0);
  
  for(int i = 0; i < n; ++i)
  {
   std::cin >> Data[i];
  }

  std::sort(Data.begin(), Data.end());
  
  int halfwayDown;
  int halfwayUp;
  
  halfwayDown = (n / 2);
  halfwayUp = (n % 2) + halfwayDown;
  
  for(int i = 0; i < halfwayDown; ++i)
  {
    std::cout << Data[halfwayUp - i - 1] << " ";
    std::cout << Data[i + halfwayUp] << " ";
  }
  
  if(n % 2 == 1)
  {
    std::cout << Data[0];
  }
  
  return 0;
}