堆-STL
往堆中加一个元素的算法(put):
#include<algorithm> void put (int d) { heap[++heap_size]=d; push_heap(heap+1,heap+heap_size+1); //大根堆 push_heap(heap+1,heap+heap_size+1,geater<int>()); //小根堆 }
从堆中取出并删除一个元素的算法(get)
#include<algorithm> void put (int d) { pop_heap(heap+1,heap+heap_size+1); //大根堆 pop_heap(heap+1,heap+heap_size+1,geater<int>()); //小根堆 heap[heap_size--]=d; }