LA 3135 (优先队列) Argus
将多个有序表合并成一个有序表就是多路归并问题,可用优先队列来解决。
#include <cstdio>
#include <queue>
using namespace std; const int maxn = + ; struct Node
{
int time, period, num;
bool operator < (const Node& rhs) const
{
return time > rhs.time || (time == rhs.time && num > rhs.num);
}
}a[maxn]; char s[]; int main()
{
//freopen("in.txt", "r", stdin); priority_queue<Node> Q;
while(scanf("%s", s) == && s[] != '#')
{
Node t;
scanf("%d%d", &t.num, &t.period);
t.time = t.period;
Q.push(t);
}
int k;
scanf("%d", &k);
while(k--)
{
Node t = Q.top(); Q.pop();
printf("%d\n", t.num);
t.time += t.period;
Q.push(t);
} return ;
}
代码君
LA 3135 (优先队列) Argus的更多相关文章
- LA 3135 优先队列
题目大意:有若干命令,它有两个属性Q_Num,Period(周期).按时间循序模拟前k个命令并输出他们的Q_Num,若同时发生输出Q_Num最小的值. #include<iostream> ...
- LA 3135 阿格斯(优先队列)
https://vjudge.net/problem/UVALive-3135 题意: 你的任务是编写一个称为Argus的系统.该系统支持一个Register的命令 Register Q_num Pe ...
- LA 3135 - Argus
看题:传送门 大意就是让你编写一个称为argus的系统,这个系统支持一个register的命令: Register Q_num Period 该命令注册了一个触发器,它每Period秒就会残生一个编 ...
- (算法入门经典大赛 优先级队列)LA 3135(之前K说明)
A data stream is a real-time, continuous, ordered sequence of items. Some examples include sensor da ...
- ACM数据结构相关资料整理【未完成,待补充】
在网上总是查不到很系统的练ACM需要学习的数据结构资料,于是参考看过的东西,自己整理了一份. 能力有限,欢迎大家指正补充. 分类主要参考<算法竞赛入门经典训练指南>(刘汝佳),山东大学数据 ...
- uva11997 K Smallest Sums&&UVALive 3135 Argus(优先队列,多路归并)
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #inc ...
- Argus UVALive - 3135(优先队列 水题一道)
有一系列的事件,它每Period秒钟就会产生编号为qNum的事件,你的任务是模拟出前k个事件,如果多个事件同时发生,先处理qNum小的事件 今天再看看数据结构.. #include <iostr ...
- 【暑假】[实用数据结构]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 ...
随机推荐
- 微信wap开发,页面显示元素不全-微信开发(asp.net)
最近在开发的微信的微商城,出现这样一种情况: pc上浏览正常,但是一到手机上浏览就会缺少部分元素 解决办法: 找了很多原因,还通过uc浏览器把网页到存下来了,发现并没有缺少元素,只是没有显示出来,后来 ...
- SQLServer 语句-创建索引【转】
语法:CREATE [索引类型] INDEX 索引名称ON 表名(列名)WITH FILLFACTOR = 填充因子值0~100GO /*实例*/USE 库名GOIF EXISTS (SELECT * ...
- Codeforces Round #311 (Div. 2) D. Vitaly and Cycle 奇环
题目链接: 点这里 题目 D. Vitaly and Cycle time limit per test1 second memory limit per test256 megabytes inpu ...
- IntelliJ IDEA 文件夹重命名--解决重命名后js文件引用找不到路径报404错误
情景: 说明:ExtJS是我后来的改的名字--原来叫extjs,可是当我把在页面的引用地址改为 src="ExtJS/.."后页面就报404错误,我把它改回之前的extjs就可以( ...
- d3d11 effect state and default value tables
Blend state State Default ValueAlphaToCoverage Enable FALSEIndependentBlend Enable FALSERenderTarget ...
- windows下几种I/O端口(了解)
如果你想在Windows平台上构建服务器应用,那么I/O模型是你必须考虑的.Windows操作系统提供了选择(Select).异步选择(WSAAsyncSelect).事件选择(WSAEventSel ...
- Linux 终端访问 FTP 及 上传下载 文件
今天同事问我一个问题,在Linux 下访问FTP,并将文件上传上去. 我之前一直是用WinSCP工具的. 先将文件从linux copy到windows下,然后在传到ftp上.google 一下. 方 ...
- AJAX请求也会重新刷新整个页面?
由于对HTML的一些内置行为不理解,所以面对今天的AJAX请求也会重新绘页面百思不得其解. 后来,请教跟伟哥同属前端组的杨成之后,才知道是由于button的默认行为导致的. 需要阻止这种标签行为,才可 ...
- C Primer Plus 第3章 数据和C 编程练习
1. /* 整数上溢 */ #include <stdio.h> int main(void) { ; unsigned ; /* 无符号整数j像一个汽车里程指示表(形容的太好了,可参考& ...
- C# 虚方法的重载 new 与 virtual
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...