D - Querying Multiset - AtCoder Beginner Contest 212(优先队列)

本文介绍了如何使用优先队列(小顶堆)解决AtCoder Beginner Contest中关于多集查询的竞赛题目。题目涉及在袋子中进行数字操作,包括添加、更新和获取最小值。通过分析思路,作者指出初始的排序方法导致超时,因此改用优先队列优化,以提高效率。
摘要由CSDN通过智能技术生成

题目描述:

Takahashi has many balls, on which nothing is written, and one bag. Initially, the bag is empty. Takahashi will do Q operations, each of which is of one of the following three types.

  • Type 1: Write an integer Xi on a blank ball and put it in the bag.

  • Type 2: For each ball in the bag, replace the integer written on it with that integer plus Xi.

  • Type 3: Pick up the ball with the smallest integer in the bag (if there are multiple such balls, pick up one of them). Record the integer written on this ball and throw it away.

For each 1≤i≤Q, you are given the type Pi of the i-th operation and the value of Xi if the operation is of Type 1 or 2. Print the integers recorded in the operations of Type 3 in order.

数据范围:

  • 1≤Q≤2×10^5

  • 1≤Pi≤3

  • 1≤Xi≤10^9

  • All values in input are integers.

  • There is one or more ii suc

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值