STL #include <iostream> #include<bits/stdc++.h> using namespace std; int a[999999]={0}; vector<int>heap; int Find(int x) { return distance(heap.begin(),find(heap.begin(),heap.end(),x)); } int main() { int n,m; cin>>n>>m; int tmp; for(int i=1;i<=n;i++) { cin>>tmp; heap.push_back(tmp); make_heap(heap.begin(),heap.end(),greater<int>()); } for(int j=1;j<=m;j++) { cin>>tmp; int top = 1; while(1) { if(top)top = 0; else printf(" "); printf("%d",heap[tmp-1]); tmp = (tmp)/2; if(tmp==0)break; } printf("\n"); } return 0; }