Problem 2681 --Heaps - Priority Queue

2681: Heaps - Priority Queue

"
Time Limit $2$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $5$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 STL

Priority Queue 

A priority queue is a data structure which maintains a set S of elements, each of with an associated value (key), and supports the following operations:

 insert(S,k)insert(S,k): insert an element k into the set S

 extractMax(S): remove and return the element of S with the largest key 

Write a program which performs the insert(S,k)insert(S,k) and extractMax(S) operations to a priority queue S. The priority queue manages a set of integers, which are also keys for the priority.

Multiple operations to the priority queue S are given. Each operation is given by "insert k", "extract" or "end" in a line. Here, k represents an integer element to be inserted to the priority queue. The input ends with "end" operation.
For each "extract" operation, print the element extracted from the priority queue S in a line.
insert 8
insert 2
extract
insert 10
extract
insert 11
extract
extract
end
8
10
11
2

The number of operations ≤2,000,000

0≤k≤2,000,000,000

推荐代码 查看2681 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战 张莹俐 435481 2019-05-30 16:36:08

赛题来源/所属竞赛 会津大学《挑战数据结构与算法》 挑战数据结构与算法

竞赛编号 竞赛名称 竞赛时间 访问比赛