zoj 2212 || poj 2051 Argus
来源:互联网 发布:路由器端口限制 编辑:程序博客网 时间:2024/05/16 12:37
又是一道水题
应用优先队列很简单。
题目要求输出前K个发送的目标
那么构造一个结构,存储period,Q_num和下一次的发送时间next就可以轻松搞定了
#include <iostream>#include <cstdio>#include <queue>using namespace std;struct Argus{ int Q_num; int period; int next; bool operator<(const Argus& rhs)const{ if (next>rhs.next) return true; if (next==rhs.next) return Q_num>rhs.Q_num; return false; }};priority_queue<Argus> que;int main(){ char s[255]; while(!que.empty()) que.pop(); while(scanf("%s",s)){ if (s[0]=='#'){ int k; scanf("%d",&k); //询问k次 for (int i=0;i<k;i++){ Argus ask; ask = que.top(); que.pop(); printf("%d\n",ask.Q_num); ask.next = ask.next+ask.period; que.push(ask); } return 0; }else{ Argus command; scanf("%d %d",&command.Q_num,&command.period); command.next = command.period; que.push(command); } } return 0;}
- zoj 2212 || poj 2051 Argus
- zoj 2212 || poj 2051 Argus
- zoj - 2212 - Argus
- POJ 2051 Argus
- poj 2051 Argus
- poj 2051 Argus
- poj 2051 Argus
- POJ--2051--Argus
- poj 2051 - Argus(堆)
- POJ 2051 Argus
- POJ 2051 Argus
- POJ 2051 Argus
- Poj 2051 Argus
- Poj 2051 Argus
- POJ 2051 Argus
- poj-2051-Argus
- poj-2051-Argus
- POJ 2051 Argus
- 程序员都应该知道的福利
- mod_python 3.3.1支持python 2.6版本的编译
- JAVA安全体系结构分析
- java程序各个组成部分
- js在开发碰到很多的逻辑分支情况解决思路
- zoj 2212 || poj 2051 Argus
- Oracle 的表的管理----表名和列的命名规则和数据类型
- OSGi中获取Service的几种方式
- 编译内核模块 error: void value not ignored as it ought to be
- 带姓名的成绩单。。。。
- VMware Workstation 9 for linux 序列号
- SQL各种连接查询
- WINPE操作系统
- android 耳机按钮深层理解