解法:
#include<iostream>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
int main() {int n;cin >> n;vector<int> arr(n);stack<int> stk;queue<int> que;for (auto& x : arr) cin >> x;for (int i = 1; i < n; i++) {if (arr[i] <= arr[0]) {stk.push(arr[i]);}else {que.push(arr[i]);}}while (!stk.empty()) {cout << stk.top() << " ";stk.pop();}cout << arr[0] << " ";while (!que.empty()) {cout << que.front() << " ";que.pop();}return 0;
}