Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- vector<long> v1;
- v1.resize(n);
- for(int i = 0; i < n; i++)
- cin>>v1[i];
- sort(v1.begin(), v1.end());
- long a = 0, b = n-1;
- for(int i = 0; i < n/2 + n%2; i++)
- {
- if(a < n/2)
- cout<<v1[a]<<' ';
- a++;
- if(b >= n/2)
- cout<<v1[b]<<' ';
- b--;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment