2013年3月18日
摘要: priority_queue调用 STL里面的 make_heap(), pop_heap(), push_heap() 算法实现,也算是堆的另外一种形式。先写一个用 STL 里面堆算法实现的与真正的STL里面的 priority_queue用法相似的priority_queue, 以加深对 priority_queue 的理解?#include <iostream>#include <algorithm>#include <vector>usingnamespacestd;classpriority_queue{private:vector<int& 阅读全文
posted @ 2013-03-18 13:44 Still_Raining 阅读(156) 评论(0) 推荐(0)
摘要: 题目链接。分析:原来是哈夫曼,想错了。比赛的时候以为水题呢。#include <stdio.h>#include <stdlib.h>#define MAXN 20010int a[MAXN];int cmp(const void *a, const void *b){ return (*(int *)a) - (*(int *)b);}int main(){ int n, i, j, t; long long ans=0; scanf("%d", &n); for(i=0; i<n; i++){ scanf("%d" 阅读全文
posted @ 2013-03-18 11:09 Still_Raining 阅读(199) 评论(0) 推荐(0)