http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1724

题目大意:

给出两种操作,GET要求取出当前队首的元素,而PUT会输入名称、值、还有优先值。

思路:

优先队列即可。

水。。

#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
struct data
{
char name[500];
int val,id;
bool operator <(const data&x)const {
return id > x.id;
}
};
int main()
{
char cmd[5];
priority_queue<data> q;
while(~scanf("%s",cmd))
{
if(cmd[0]=='G')
{
if(!q.empty())
{
data temp=q.top();
q.pop();
printf("%s %d\n",temp.name,temp.val);
}
else puts("EMPTY QUEUE!");
}
else
{
data temp;
scanf("%s%d%d",temp.name,&temp.val,&temp.id);
q.push(temp);
}
}
return 0;
}

zoj 2724 Windows Message Queue 优先队列的更多相关文章

  1. zoj 2724 Windows Message Queue

    Windows Message Queue Time Limit: 2 Seconds      Memory Limit: 65536 KB Message queue is the basic f ...

  2. zoj 2724 Windows Message Queue(使用priority_queue容器模拟消息队列)

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2724 题目描述: Message queue is the b ...

  3. ZOJ 2724 Windows Message Queue (二叉堆,优先队列)

    思路:用优先队列 priority_queue,简单 两种方式改变队列 的优先级 (默认的是从大到小) #include<iostream> #include<queue> # ...

  4. ACM解题之(ZOJ 2724)Windows Message Queue

    题目来源: 点击打开链接 题目翻译: 消息队列是windows系统的基本基础.对于每个进程,系统都维护一个消息队列.如果这个过程发生某些事情,例如鼠标点击,文本改变,系统会向队列添加一条消息.同时,如 ...

  5. ZOJ 2724 Windows Message Queue (优先级队列,水题,自己动手写了个最小堆)

    #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm& ...

  6. hdu 1509 Windows Message Queue (优先队列)

    Windows Message QueueTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  7. Windows Message Queue(优先队列)

    欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Windows Message Queue Time Limit: 2000/1000 MS (Java/Others)    Mem ...

  8. hdoj 1509 Windows Message Queue【优先队列】

    Windows Message Queue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot ...

  9. hdu 1509 Windows Message Queue

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1509 Windows Message Queue Description Message queue ...

随机推荐

  1. [UnityUI]循环滑动列表

    效果图: 使用的是UGUI和DOTween 当中比較关键的是循环滑动和层次排序: 1.循环滑动:这里先如果显示五张图片.分别标记为0,1,2,3,4,那么当向左滑动时,序列就变为1,2,3,4,0,这 ...

  2. 认识 Atlassian Datacenter 产品

    认识 Atlassian Datacenter 产品 云端原本就是群集化的架构,Atlassian 系列产品.应用的开发团队相当广范且行之有年,可是将应用程序作为节点(比方Jira,confluenc ...

  3. vue的指令在webstrom下报错

    Preferences -> Editor -> Inspections找到XML,把 Unbound XML namespace prefix的勾去掉

  4. sqlserver 小计合计总计

    SELECT CASE WHEN GROUPING(F1) = 1 THEN '总计'WHEN GROUPING(F1) = 0 AND GROUPING(F2) = 1 THEN  F1+'合计'W ...

  5. Android webview 运行时不调用系统自带浏览器

    WebView mobView = new WebView(this); mobView.loadUrl("http://www.csdn.net"); WebSettings w ...

  6. javafx DragDropped file

    public class EffectTest extends Application { @Override public void start(Stage primaryStage) { Grou ...

  7. nohup---将程序以忽略挂起信号的方式运行起来

    nohup nohup命令:如果你正在运行一个进程,而且你觉得在退出帐户时该进程还不会结束,那么可以使用nohup命令.该命令可以在你退出帐户/关闭终端之后继续运行相应的进程. 在缺省情况下该作业的所 ...

  8. 9.使用 npm 命令安装模块

    转自:http://www.runoob.com/nodejs/nodejs-tutorial.html npm 安装 Node.js 模块语法格式如下: $ npm install <Modu ...

  9. Android Okhttp完美同步持久Cookie实现免登录

    通过对Retrofit2.0的<Retrofit 2.0 超能实践,完美支持Https传输>基础入门和案例实践,掌握了怎么样使用Retrofit访问网络,加入自定义header,包括加入S ...

  10. 3/18 Django框架 启动django服务

    web框架:本质是socket服务端,socket通常也被称为"套接字",用于描述IP地址和端口,是一个通信链的句柄,可以用来实现不同虚拟机或不同计算机之间的通信.web框架就是将 ...