被暴力插排 200ms 过了。
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
vector<int> v;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n; cin >> n; v.resize(n); for (int i(0); i<n; ++i) cin >> v[i];
for (auto i = v.begin(); i != v.end(); ++i)
std::rotate(std::upper_bound(v.begin(), i, *i), i, i + 1);
for (auto i: v) cout << i << ' ';
}
别问我为什么码风这么奇怪