结构体优先队列的用法

本文介绍了结构体优先队列在功能性模板中的使用方法,主要适用于编程问题的解决和查找。
摘要由CSDN通过智能技术生成
今天做一个微软的校招笔试题 Registration Day ,用优先队列模拟操作的。粘贴来别人的代码,谨记 pq 的用法。另外 memset 包含在 string.h 里。

 1 #include <stdio.h>
 2 #include <string.h>
 3 #include <limits.h>
 4 #include <queue>
 5 #include <vector>
 6 #include <set>
 7 #include <map>
 8 #include <algorithm>
 9 
10 using namespace std;
11 
12 int N, M, K;
13 struct Student
14 {
15     int id;
16     int arrive_time;
17     int office_num;
18     int finish_time;
19     std::vector<pair<int, int> > register_offices;
20 };
21 Student students[10005];
22 struct Event
23 {
24     int student_idx;
25     int office;
26     int begin;
27     int duration;
28     Event(int s, int o, int b, int d): student_idx(s), office(o), begin(b), duration(d){};
29 };
30 struct Cmp
31 {
32     bool operator()(const Event &e1, const Event &e2){
33         if (e1.begin == e2.begin)
34      
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值