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 ...
随机推荐
- python-安装xlrd xlwt 插件
最近需要对比两个表格的内容,然后修改其中的某列内容.因为工作量太大,所以想通过python来实现.上网查了相关的操作,其中牵扯到两个功能模块,xlrd xlwt.这两个功能模块分别是对excel进行读 ...
- vs2010 Visula C++ 把CString 转换为string 类型
CString strSomeCstring ("This is a CString Object"); // Use ANSI variant CStringA to conve ...
- uname 命令
uname -p 显示系统的芯片类型.如,PowerPC uname -r 显示操作系统的版本号 uname -s 显示系统名称.例如,AIX uname -n 显示节点名称 uname -a 显示系 ...
- Vue 学习记录<2>
一.Vue https://vue-loader.vuejs.org/zh-cn/ https://vuejs-templates.github.io/webpack/structure.html
- Windows 98 二十岁了,这些功能都是从它开始的(虽然 Windows 98 不如 Windows 95 那样具有革命性,但完成度更高,更加成熟。到最后还是:相见不如怀念。)
1998 年 6 月 25 日午夜,美国著名连锁零售店 CompUSA 门外挤满了狂热的消费者和媒体,他们在等待一款软件发售:Windows 98,即使明知它要到当天早上才正式上市. ▲ 在 Comp ...
- python实现获取文件列表中每一个文件keyword
功能描写叙述: 获取某个路径下的全部文件,提取出每一个文件里出现频率最高的前300个字.保存在数据库其中. 前提.你须要配置好nltk #!/usr/bin/python #coding=utf-8 ...
- holder.js如何使用
holder.js的使用 一.总结 一句话总结:使用:holder.js后面接图片宽高 <img src="holder.js/300x200" /> 1.holder ...
- 1.23 Python知识进阶 - 面向对象编程
一.编程方法 1.函数式编程:"函数式编程"是一种"编程范式"(programming paradigm),也就是如何编写程序的方法论.它属于"结构化 ...
- BIND View 加速南北方网络互访
BIND View 加速南北方网络互访 南北方网络互访的问题一直以来就是广大运维人员的心病,两大网络运营商之间的连接带宽比较有限,跟不上互联网业务发展的速度.如何才能 ...
- Spring异步执行(@Async)2点注意事项
Spring中可以异步执行代码,注解方式是使用@Async注解. 原理.怎么使用,就不说了. 写2点自己遇到过的问题. 1.方法是公有的 // 通知归属人 @Async public void not ...