#include<iostream> #include<stdlib.h> usingnamespacestd; constint maxn = 1e6 + 1; int h[maxn]; int n, m; int Size = 0; voidinsert(int x){ Size++; int i; for (i = Size; x < h[i / 2]; i /= 2) { h[i] = h[i / 2]; } h[i] = x; }
intmain(){ cin >> n >> m; int i; h[0] = -100001; for (i = 1; i <= n; i++) { int t; cin >> t; insert(t); } while (m--) { int t; cin >> t; for (i = t; i >= 1; i /= 2) { if (i == t) cout << h[i]; elsecout <<" "<< h[i]; } cout << endl; } system("pause"); return0;