
优先队列,队列,栈,堆
文章平均质量分 52
_Griffith
每天都要学习新知识
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
优先队列
说到队列,我们首先想到就是先进先出,后进后出;那么何为优先队列呢,在优先队列中,元素被赋予优先级,当访问元素时,具有最高级优先级的元素先被访问。即优先队列具有最高级先出的行为特征。 优先队列在头文件#include 中; 其声明格式为:priority_queue ans;//声明一个名为ans的整形的优先队列 基本操作有: empty( ) //判断一个队列是否为空 pop( )转载 2017-07-11 21:59:31 · 268 阅读 · 0 评论 -
B - Fence Repair (优先队列)
Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000) planks of wood, each having some integer length Li (1 ≤ Li原创 2017-07-19 13:42:22 · 373 阅读 · 0 评论 -
用c语言实现链栈 (带头结点)
#include #include #include #include #include using namespace std; typedef struct Node { int element; struct Node* next; }Node; ///创建空的栈 Node *creatstack() { Node *s = (Node *)malloc(sizeo原创 2017-08-09 22:04:03 · 2534 阅读 · 0 评论 -
求最大子数列的和
给一段数列,(有可能为负数),找出其中一段子数列,使得这段子数列中的所有元素和最大,如果所求的和为负数,请输出0 1.分治思想(时间复杂度为O(n*logn) ) #include #include #include using namespace std; int max3(int a,int b,int c) { int mid; mid = max(a,b); return原创 2017-08-06 17:25:17 · 430 阅读 · 0 评论