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 ...
随机推荐
- bnuoj 33656 J. C.S.I.: P15(图形搜索题)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=33656 [题解]:暴力搜索题 [code]: #include <iostream> # ...
- ffmpeg 编码
编码可以简单理解为将连续的图片帧转变成视频流的过程.以H264为例给出编码的代码: int InitEncoderCodec(int width, int height) { auto enc = a ...
- hadoop 数据采样
http://www.cnblogs.com/xuxm2007/archive/2012/03/04/2379143.html 原文地址如上: 关于Hadoop中的采样器 .为什么要使用采样器 在这个 ...
- hlsl 和cg 涉及 mul 左乘 右乘
error: 1. mul' implicit truncation of vector type 2. matrixXXX: array dimensions of(unknown scope en ...
- 什么是REST架构(转)
REST架构风格是全新的针对Web应用的开发风格,是当今世界最成功的互联网超媒体分布式系统架构,它使得人们真正理解了Http协议本来面貌.随着 REST架构成为主流技术,一种全新的互联网网络应用开发的 ...
- REST和SOAP Web Service的区别比较
本文转载自他人的博客,ArcGIS Server 推出了 对 SOAP 和 REST两种接口(用接口类型也许并不准确)类型的支持,本文非常清晰的比较了SOAP和Rest的区别联系! ///////// ...
- Sublime Text 3 搭建 React.js 开发环境
sublime有很强的自定义功能,插件库很庞大,针对新语言插件更新很快,配合使用可以快速搭建适配语言的开发环境. 1. babel 支持ES6, React.js, jsx代码高亮,对 JavaScr ...
- Asp.Net缓存(2)
缓存页的多个版本 ASP.NET 允许在输出缓存中缓存同一页的多个版本.输出缓存可能会因下列因素而异: 初始请求 (HTTP GET) 中的查询字符串. 回发时传递的控制值(HTTP POST 值). ...
- sun.misc.unsafe类的使用
http://blog.csdn.net/fenglibing/article/details/17138079
- 【Linux高频命令专题(3)】uniq
简述 用途 报告或删除文件中重复的行. 语法 uniq [ -c | -d | -u ] [ -f Fields ] [ -s Characters ] [ -Fields ] [ +Characte ...