Argus
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的更多相关文章
- poj 2051.Argus 解题报告
题目链接:http://poj.org/problem?id=2051 题目意思:题目有点难理解,所以结合这幅图来说吧---- 有一个叫Argus的系统,该系统支持一个 Register 命令,输入就 ...
- 【暑假】[实用数据结构]UVAlive 3135 Argus
UVAlive 3135 Argus Argus Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %l ...
- LA-3135 - Argus(优先队列)
3135 - Argus A data stream is a real-time, continuous, ordered sequence of items. Some examples incl ...
- poj2051 Argus
Description A data stream is a real-time, continuous, ordered sequence of items. Some examples inclu ...
- UVA 1203 - Argus(优先队列)
UVA 1203 - Argus 题目链接 题意:给定一些注冊命令.表示每隔时间t,运行一次编号num的指令.注冊命令结束后.给定k.输出前k个运行顺序 思路:用优先队列去搞,任务时间作为优先级.每次 ...
- uva 1203 - Argus(优先队列)
option=com_onlinejudge&Itemid=8&page=show_problem&problem=3644" target="_blank ...
- Winter-2-STL-A Argus 解题报告及测试数据
Time Limit:2000MS Memory Limit:65536KB Description A data stream is a real-time, continuous, ord ...
- ACM解题之(ZOJ 2212) Argus
题目来源: 点击打开题目 题目翻译: 数据流是实时的,连续的,有序的项目序列.一些例子包括传感器数据,互联网流量,金融代码,在线拍卖以及诸如网络使用日志和电话记录之类的交易日志.同样,对流进行的查询在 ...
- POJ 2051 Argus
Argus Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8782 Accepted: 3985 Description ...
随机推荐
- 配置hibernate根据实体类自动建表功能(转载)
hibernate支持自动建表,在开发阶段很方便,可以保证hbm与数据库表结构的自动同步. 如何使用呢?很简单,只要在hibernate.cfg.xml里加上如下代码 Xml代码<propert ...
- codeforces 520 Pangram
http://codeforces.com/problemset/problem/520/A A. Pangram time limit per test 2 seconds memory limit ...
- Windows服务安装异常:System.Security.SecurityException: 未找到源,但未能搜索某些或全部事件日志。不可 访问的日志: Security
Windows服务安装异常:System.Security.SecurityException: 未找到源,但未能搜索某些或全部事件日志.不可 访问的日志: Security 2种方法处理: 一.右键 ...
- EBS 密码相关
SELECT usr.user_name, apps.cux_fnd_web_sec.decrypt ((SELECT (SELECT apps.cux_fnd_web_sec.decrypt (fn ...
- json和字符串/数组/集合的互相转换の神操作总结
一:前端字符串转JSON的4种方式 1,eval方式解析,恐怕这是最早的解析方式了. function strToJson(str){ var json = eval('(' + str + ')') ...
- 夺命雷公狗ThinkPHP项目之----企业网站16之文章列表页的完善(关联查询)
我们栏目的所属栏目不能总是以数字来显示吧??这样的话,估计老板会让您直接卷铺盖滚蛋噢,嘻嘻... 所以我们需要对她进行关联查询,控制器代码如下所示: public function lists(){ ...
- PAT乙级 1030. 完美数列(25)
1030. 完美数列(25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CAO, Peng 给定一个正整数数列,和正整数p,设这 ...
- 【海岛帝国系列赛】No.5 海岛帝国:独立之战
50229234海岛帝国:独立之战 [试题描述] 恐怖分子多年来一直如饥似渴地渴求“药师傅”帝国,但是,“里脊肉”BANNIE时刻在守护着这一方水土.从而使帝国日益强大.如今,BANNIE由于在 “牡 ...
- wangEditor——轻量化web富文本框
wangEditor——轻量级web富文本编辑器 参见:wangEditor.github.io 或者 https://github.com/wangfupeng1988/wangEditor 交 ...
- Android自动化压力测试快速入门教程(图解)——MonkeyRunner
一.MonkeyRunner测试环境配置(转自) 1. android-sdk 下载地址:http://www.android-doc.com/sdk/index.html 下载完成后,只需要解压就 ...