提交时间:2024-07-17 11:22:59

运行 ID: 156415

#include<iostream> using namespace std; const int N = (1 << 20) + 10; int n, a[N], t, mx = 0; void insert(int root, int x){ mx = max(root, mx); if(a[root] == 0){ a[root] = x; return; } if(a[root] > x) insert(root * 2, x); else insert(root * 2 + 1, x); } int main(){ int n; cin >> n; for(int i = 0; i < n; i++){ cin >> t; insert(1, t); } for(int i = 1; i <= mx; i++){ cout << a[i] << ' '; } return 0; }