Argus  

时间限制(普通/Java):1000MS/3000MS     运行内存限制:65536KByte
总提交: 3            测试通过: 2

描述

A data stream is a real-time, continuous, ordered sequence of items. Some examples include sensor data, Internet traffic, financial tickers, on-line auctions, and transaction logs such as Web usage logs and telephone call records. Likewise, queries over streams run continuously over a period of time and incrementally return new results as new data arrives. For example, a temperature detection system of a factory warehouse may run queries like the following.

Query-1: "Every five minutes, retrieve the maximum temperature over the past five minutes."
Query-2: "Return the average temperature measured on each floor over the past 10 minutes."

We have developed a Data Stream Management System called Argus, which processes the queries over the data streams. Users can register queries to the Argus. Argus will keep the queries running over the changing data and return the results to the corresponding user with the desired frequency.

For the Argus, we use the following instruction to register a query:

Register Q_num Period

Q_num (0 < Q_num <= 3000) is query ID-number, and Period (0 < Period <= 3000) is the interval between two consecutive returns of the result. After Period seconds of register, the result will be returned for the first time, and after that, the result will be returned every Period seconds.

Here we have several different queries registered in Argus at once. It is confirmed that all the queries have different Q_num. Your task is to tell the first K queries to return the results. If two or more queries are to return the results at the same time, they will return the results one by one in the ascending order of Q_num.

输入

The first part of the input are the register instructions to Argus, one instruction per line. You can assume the number of the instructions will not exceed 1000, and all these instructions are executed at the same time. This part is ended with a line of "#".

The second part is your task. This part contains only one line, which is one positive integer K (<= 10000).

输出

You should output the Q_num of the first K queries to return the results, one number per line.

样例输入

Register 2004 200
Register 2005 300
#
5

样例输出

2004
2005
2004
2004
2005

题目来源

Beijing 2004

题目上传者

crq

#include <iostream>
#include <string>
#include <queue>
using namespace std;struct Instrut
{int id;double ReturnTime; double period;Instrut(int i, double p):id(i), ReturnTime(p), period(p){}};bool operator < (const Instrut& x, const Instrut& y)
{if(x.ReturnTime != y.ReturnTime)return x.ReturnTime > y.ReturnTime;return x.id > y.id;
}int main()
{string str;int k, id, period;priority_queue<Instrut> que;for(int i = 0; cin >> str; ++i){if(str == "#") break;elsecin >> id >> period;Instrut tmp(id, period);que.push(tmp);}cin >> k;while(k--){Instrut tmp = que.top();que.pop();cout << tmp.id << endl;tmp.ReturnTime += tmp.period;que.push(tmp);}return 0;
}

Argus(ZOJ Problem Set - 2212)(优先队列)相关推荐

  1. ZOJ Problem 1005 jugs

    题目 In the movie "Die Hard 3", Bruce Willis and Samuel L. Jackson were confronted with the ...

  2. Beta Round #43 (ACM-ICPC Rules), problem: (E) Comb 优先队列+晦涩题意

    题意:给定n个数列,每个数列的长度为m,在i数列中从头取连续的ci个数字,最后要满足c1>c2<c3....问这些数字最大和是多少. 做法:根据行数的不同,构造队列的方法要适当改变,可以优 ...

  3. ZOJ Problem Set - 1331 Perfect Cubes

    这个题啊,一看就是暴力,暴力,暴力!!! 但是,暴力也是要做到暴力的恰到好处:看题 For hundreds of years Fermat's Last Theorem, which stated ...

  4. ZOJ Problem Set - 1048 Financial Management

    我承认这是一道水的不能再水的题,今天一下就做到了,还是无耻的帖上来吧 #include <stdio.h>int main() {double sum=0;for(int i=1;i< ...

  5. ZOJ Problem Set - 3329 One Person Game

    题目大意:有三个骰子,分别有k1,k2,k3个面. 每次掷骰子,如果三个面分别为a,b,c则分数置0,否则加上三个骰子的分数之和. 当分数大于n时结束.求游戏的期望步数.初始分数为0分析 设 E[i] ...

  6. ZOJ Problem Set - 1730 Crazy Tea Party

    #include<cstdio> int main(){int T,n;scanf("%d",&T);while(T--){scanf("%d&quo ...

  7. ZOJ Problem Set - 1067 Color Me Less

    这道题目很简单,考察的就是结构体数组的应用,直接贴代码了 #include <stdio.h> #include <math.h>typedef struct color {i ...

  8. ZOJ Problem Set - 1008

    1.翻译及思路 http://blog.csdn.net/dapengbusi/article/details/7313785 http://acm.sdut.edu.cn/bbs/read.php? ...

  9. ZOJ Problem Set - 1009

    1.参考 http://blog.csdn.net/xiaogugood/article/details/17922105 这篇博客对算法介绍的很详细,我看这道题的时候,将题目理解出错,所以进入了一个 ...

最新文章

  1. LeetCode简单题之比较含退格的字符串
  2. 【全网最精简】一行代码解决千万位以上的数字格式化为银行金额数字格式(如:¥1,000,000,000.00)
  3. 用aspnetpager实现datalist分页(绝对的简单实用)
  4. spring源码解析之IOC容器(二)------加载和注册
  5. Activity和Service通信 使用BroadcastReceiver
  6. 爱因斯坦为什么不是普通人?看他怎么喝茶就明白了,差距太明显了!没法比.......
  7. python对找到的匹配项作处理后再替换回去
  8. Linux crypto相关知识的汇总 Linux加密框架crypto对称算法和哈希算法加密模式
  9. SpringBoot2 整合 ClickHouse数据库,实现高性能数据查询分析
  10. 华为搭载鸿蒙系统的手表,华为手表Watch 3即将发布:搭载鸿蒙系统
  11. uwp - ContentDialog - 自定义仿iphone提示框,提示框美化
  12. 读取SD卡文件夹下的MP3文件和播放MP3文件
  13. HGET key field
  14. 阿里云Oss水印图片处理Utils
  15. EasyPlayer-Android互联网直播视频播放器是如何实现播放器退到后台后再回到前台时,播放画面无缝衔接?
  16. 远程控制 - 手机完全控制电脑之TeamViewer
  17. ios 纯代码怎么适配ipad_iPad横竖屏下的代码适配
  18. Type-C强光手电快充方案
  19. T解 湖南师大附中集训 模拟考试1
  20. Window 电脑C盘清理

热门文章

  1. C-指针,二级指针,二维数组作为函数参数使用,C语言链表(详解)
  2. 加班越久故障越多,如何跳出程序员的恶性循环?
  3. Cookie简单使用方法
  4. ios打包ipa的四种实用方法
  5. 了解JavaScript 对象的属性操作
  6. CSS修改tr边框属性
  7. 汇编指令 DUP指令
  8. [EffectiveC++]item32:确定你的public继承模塑出is-a关系
  9. 【奇淫巧技】XSS绕过技巧
  10. bzoj 5340: [Ctsc2018]假面