Argus

Time Limit: 1000MS Memory Limit: 30000K

Total Submissions: 10186 Accepted: 4801

Description

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.

Input

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).

Output

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

Sample Input

Register 2004 200

Register 2005 300

#

5

Sample Output

2004

2005

2004

2004

2005

Source

Beijing 2004

优先队列的简单应用

#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include <queue>
#include <algorithm> using namespace std; const int INF = 0x3f3f3f3f; const int MAX = 55000; struct node
{
int ID;
int Period;
int time;
}a; bool operator < (node b,node c)
{
if(b.time>c.time||(b.time==c.time&&b.ID>c.ID))
{
return true;
}
return false;
} int main()
{
string c;
int k;
priority_queue<node>Q;
while(cin>>c&&c!="#")
{
cin>>a.ID>>a.Period;
a.time=a.Period;
Q.push(a);
}
cin>>k;
for(int i=1;i<=k;i++)
{
a=Q.top();
Q.pop();
cout<<a.ID<<endl;
a.time+=a.Period;
Q.push(a);
}
return 0;
}

Argus的更多相关文章

  1. poj 2051.Argus 解题报告

    题目链接:http://poj.org/problem?id=2051 题目意思:题目有点难理解,所以结合这幅图来说吧---- 有一个叫Argus的系统,该系统支持一个 Register 命令,输入就 ...

  2. 【暑假】[实用数据结构]UVAlive 3135 Argus

    UVAlive 3135 Argus Argus Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %l ...

  3. LA-3135 - Argus(优先队列)

    3135 - Argus A data stream is a real-time, continuous, ordered sequence of items. Some examples incl ...

  4. poj2051 Argus

    Description A data stream is a real-time, continuous, ordered sequence of items. Some examples inclu ...

  5. UVA 1203 - Argus(优先队列)

    UVA 1203 - Argus 题目链接 题意:给定一些注冊命令.表示每隔时间t,运行一次编号num的指令.注冊命令结束后.给定k.输出前k个运行顺序 思路:用优先队列去搞,任务时间作为优先级.每次 ...

  6. uva 1203 - Argus(优先队列)

    option=com_onlinejudge&Itemid=8&page=show_problem&problem=3644" target="_blank ...

  7. Winter-2-STL-A Argus 解题报告及测试数据

    Time Limit:2000MS     Memory Limit:65536KB Description A data stream is a real-time, continuous, ord ...

  8. ACM解题之(ZOJ 2212) Argus

    题目来源: 点击打开题目 题目翻译: 数据流是实时的,连续的,有序的项目序列.一些例子包括传感器数据,互联网流量,金融代码,在线拍卖以及诸如网络使用日志和电话记录之类的交易日志.同样,对流进行的查询在 ...

  9. POJ 2051 Argus

    Argus Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 8782   Accepted: 3985 Description ...

随机推荐

  1. zabbix服务器监控suse系统教程

    zabbix服务器监控suse系统教程 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 花了近一个星期才学会了如何监控window和linux主机的基本信息以及报价情况(我已经把笔记 ...

  2. set和map和pair 转自ACdreamers

    set与map容器         分类:             C/C++              2013-08-25 19:21     560人阅读     评论(0)     收藏    ...

  3. 全局函数VS成员函数

    #include <iostream> using namespace std; class Test { public: Test(int a, int b) { this->a ...

  4. 2013年各大小IT公司待遇

    2013年各大小IT公司待遇(初版   摘自好网)本人西电硕士,根据今年找工作的情况以及身边同学的汇总,总结各大公司的待遇如下,吐血奉献给各位学弟学妹,公司比较全,你想去的公司不在这里面,基本上是无名 ...

  5. Android -- 自定义View小Demo(一)

    1,现在要实现下图的简单效果,很简单  ,就是使用paint在canvas上绘制5中不同颜色的圆圈,效果图如下: 这是绘制基本图形一种最简单的方法,下面是它的代码 ,注释写的很详细,也就不去讲解了 M ...

  6. Oracle重置序列(不删除重建方式)

    Oracle中一般将自增sequence重置为初始1时,都是删除再重建,这种方式有很多弊端,依赖它的函数和存储过程将失效,需要重新编译. 不过还有种巧妙的方式,不用删除,利用步长参数,先查出seque ...

  7. ubuntu SVN环境配置(转)

    一.SVN安装1.安装包$ sudo apt-get install subversion 2.添加svn管理用户及subversion组$ sudo adduser svnuser$ sudo ad ...

  8. BI案例:BI在连锁零售业应用(ZT)【转】

    第一部分:连锁零售企业上BI的必要性. 目前国内的连锁零售行业的发展趋势,呈现出产业规模化,经营业态多样化,管理精细化的特点.所谓管理精细化就是"精耕细作搞管理,领先一步订系 统" ...

  9. android 项目学习随笔九(ListView加头布局)

    1.缓冲背景色 <ListView android:id="@+id/lv_list" android:layout_width="match_parent&quo ...

  10. win7 chm 打开失败记录

    近期学习rails,制作的html帮助文件想生成chm文件,用了几个网上的html制作chm软件,生成的chm无法打开. 网上大部分解决方法是修改文件属性,Unlock之后可解决. 以前遇到过打不开, ...