堆
#include<iostream> #include<cstdio>#include<cmath>#include<cstring>using namespace std;int heap[101];int heapSize;void put(int);void get();int main(){ int x;cin>>x; put(x); return 0;}void put(int d){ int now,next; heap[++heapSize] = d; now = heapSize; while(now > 1) { next=now >> 1; if(heap[now] >= heap[next])break; swap(heap[now],heap[next]); now = next; }}void get(){ int now,next,res; res = heap[1]; heap[1]=heap[heapSize--]; now = 1; while(now * 2 <= heapSize) { next = now * 2; if(next < heapSize && heap[next+1] < heap[next])next++; if(heap[now] <= heap[next]) break; swap(heap[now],heap[next]); now = next; } return res;}