提交时间:2024-07-17 11:19:35
运行 ID: 156409
#include<iostream> using namespace std; const int N = 20; int n, a[N * 100], 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; }