堆
SSL_GYX
座右铭:言念君子,温其如玉。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【ybt】【数据结构 二分堆 课过 例4】工作安排
工作安排 题目链接:工作安排 题目描述 解题思路 我们先以时间为第一关键字、利润为第二关键字排序,然后贪心,在当前时间内选最大的利润。 code #include<algorithm> #include<iostream> #include<cstdio> #include<queue> #define int long long using namespace std; priority_queue<int> q; int n,m; in原创 2021-05-05 10:41:41 · 114 阅读 · 0 评论 -
【ybt】【数据结构 二分堆 课过 例1】合并果子
合并果子 题目链接:合并果子 题目描述 解题思路 贪心,每次取最小的两堆合并,用堆处理。 code #include<iostream> #include<cstdio> #include<queue> using namespace std; priority_queue<int> q; int n; int ans; int main() { cin>>n; for(int i=1;i<=n;i++) { int a;原创 2021-05-04 16:29:06 · 146 阅读 · 0 评论 -
【ybt】【数据结构 二分堆 课过 例3】龙珠游戏
龙珠游戏 题目链接:龙珠游戏 题目描述 解题思路 贪心,堆处理。 code #include<iostream> #include<cstdio> #include<queue> using namespace std; priority_queue<pair<int,int> > q; int n; int a[100010]; int v[100010]; int nxt[1000010]; void get() { int t=q原创 2021-05-05 08:41:48 · 157 阅读 · 0 评论 -
【ybt】【数据结构 二分堆 课过 例2】序列合并
序列合并 题目链接:序列合并 题目描述 解题思路 我们可以把它当成贪心来想: 首先将 aaa 数列的第一个与 bbb 数列的每一个匹配,用堆储存,每次取最小值,在将 aaa 数列向后移一位进行匹配,重复 nnn 遍。 code #include<iostream> #include<cstdio> #include<queue> using namespace std; priority_queue<pair<int,pair<int,int>原创 2021-05-05 08:35:37 · 143 阅读 · 0 评论
分享