LA 3135 - Argus
大意就是让你编写一个称为argus的系统,这个系统支持一个register的命令: Register Q_num Period
该命令注册了一个触发器,它每Period秒就会残生一个编号为 Q_num的事件。你的任务就是模拟出前k个事件。如果多个事情同时发生,先处理Q_num小的事件。
优先队列的使用。
练习了用struct类自定义优先级。
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
using namespace std;
struct order
{
int qnum,period,time;
bool operator <(const order &a)const{
return time > a.time||(time==a.time&& qnum > a.qnum) ;
}
};
int main()
{
priority_queue<order> a;
char x[10];
while(scanf("%s",x),strcmp(x,"#"))
{
order temp;
scanf("%d%d",&temp.qnum,&temp.period);
temp.time=temp.period;
a.push(temp);
}
int k;
scanf("%d",&k);
while(k--)
{
order temp=a.top();
a.pop();
printf("%d\n",temp.qnum);
temp.time+=temp.period;
a.push(temp);
}
}
LA 3135 - Argus的更多相关文章
- 【暑假】[实用数据结构]UVAlive 3135 Argus
UVAlive 3135 Argus Argus Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %l ...
- LA 3135 (优先队列) Argus
将多个有序表合并成一个有序表就是多路归并问题,可用优先队列来解决. #include <cstdio> #include <queue> using namespace std ...
- (算法入门经典大赛 优先级队列)LA 3135(之前K说明)
A data stream is a real-time, continuous, ordered sequence of items. Some examples include sensor da ...
- LA 3135 阿格斯(优先队列)
https://vjudge.net/problem/UVALive-3135 题意: 你的任务是编写一个称为Argus的系统.该系统支持一个Register的命令 Register Q_num Pe ...
- uva11997 K Smallest Sums&&UVALive 3135 Argus(优先队列,多路归并)
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #inc ...
- uvalive 3135 Argus priority_queue
用优先队列维护每个时间点优先级最高的元素. #include<iostream> #include<cstdio> #include<cstdlib> #inclu ...
- uvalive 3135 Argus
https://vjudge.net/problem/UVALive-3135 题意: 有一个系统有多个指令,每个指令产生一个编号为qnum的时间,每个指令的触发间隔不相同,现在给出若干个指令,现在的 ...
- LA 3135 优先队列
题目大意:有若干命令,它有两个属性Q_Num,Period(周期).按时间循序模拟前k个命令并输出他们的Q_Num,若同时发生输出Q_Num最小的值. #include<iostream> ...
- LA-3135 - Argus(优先队列)
3135 - Argus A data stream is a real-time, continuous, ordered sequence of items. Some examples incl ...
随机推荐
- 33.IDEA + maven]在IDEA中打开一个maven项目,resolve完依赖后,缺少部分jar包问题
转自:https://www.cnblogs.com/zazalu/p/7649590.html [注意]作者只是对使用过程中遇到的问题提出了一个解决方案,但是本人在编写此解决方案文章的时候,对mav ...
- mapper.xml中的常用标签
mybatis的mapper xml文件中的常用标签 https://blog.csdn.net/qq_41426442/article/details/79663467 SQL语句标签 1.查询语句 ...
- 【hdu 4289】Control
[Link]:http://acm.hdu.edu.cn/showproblem.php?pid=4289 [Description] 给出一个又n个点,m条边组成的无向图.给出两个点s,t.对于图中 ...
- Java基础学习总结(21)——常用正则表达式列表
很多不太懂正则的朋友,在遇到需要用正则校验数据时,往往是在网上去找很久,结果找来的还是不很符合要求.所以我最近把开发中常用的一些正则表达式整理了一下,包括校验数字.字符.一些特殊的需求等等.给自己留个 ...
- Resource Access Based on Multiple Credentials
A collection of multiple user credentials each associated with one of multiple different users is ob ...
- 如何通过使用fiddler对Android系统设备抓包总结
http://www.open-open.com/lib/view/open1427509907668.html
- 洛谷——P1307 数字反转
https://www.luogu.org/problem/show?pid=1307#sub 题目描述 给定一个整数,请将该数各个位上数字反转得到一个新数.新数也应满足整数的常见形式,即除非给定的原 ...
- STL_算法_查找算法(search、find_end)
C++ Primer 学习中. .. 简单记录下我的学习过程 (代码为主) search //从左往右找第一个符合条件的子区间 全部容器适用 find_end //从右往左找 ...
- Qt虽然自己的源代码里不使用Exception,但也提供了一个QException及其子类QUnhandledException
http://doc.qt.io/qt-5/exceptionsafety.htmlhttp://doc.qt.io/qt-5/qexception.htmlhttp://doc.qt.io/qt-5 ...
- 小胖说事29-----iOS中Navigation中左滑pop页面的三种方法
第三中类型.自己定义任何位置返回页面的方式,上边的类就是.m,大家能够贴过去使用.这个类是继承NavigationController的.用这个类初始化rootController就能够了.这里还有源 ...