HDU 4557
http://acm.hdu.edu.cn/showproblem.php?pid=4557
解决一类问题的set用法
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <map> using namespace std ; char na[][] ; int main()
{
int T ;
scanf("%d",&T) ;
multiset <int> S[] ;
for(int cas= ;cas<=T ;cas++)
{
for(int i= ;i< ;i++)
S[i].clear() ;
int n ;
scanf("%d",&n) ;
printf("Case #%d:\n",cas) ;
int cnt= ;
int num= ;
while(n--)
{
char op[] ;
scanf("%s",op) ;
if(op[]=='A')
{
int x ;
scanf("%s%d",na[num],&x) ;
S[x].insert(num++) ;
printf("%d\n",++cnt) ;
}
else
{
int x ;
scanf("%d",&x) ;
int flag= ;
for(int i=x ;i<= ;i++)
{
if(!S[i].empty())
{
multiset <int>::iterator it ;
it=S[i].lower_bound() ;
if(it!=S[i].end())
{
flag= ;
printf("%s\n",na[*it]) ;
S[i].erase(it) ;
cnt-- ;
break ;
}
}
}
if(!flag)
{
puts("WAIT...") ;
}
}
}
}
return ;
}
HDU 4557的更多相关文章
- HDU 4557 非诚勿扰(Treap找后继)
非诚勿扰 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Submi ...
- HDU 4557 Tree(可持久化字典树 + LCA)
http://acm.hdu.edu.cn/showproblem.php?pid=4757 题意: 给出一棵树,每个结点有一个权值,现在有多个询问,每次询问包含x,y,z三个数,求出在x到y的路径上 ...
- hdu 4557 非诚勿扰
水题…… 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<io ...
- hdu 4557 非诚勿扰 vector的应用 原来vector 可以删除指定位置元素 不过消耗大
非诚勿扰 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Submi ...
- HDU 4557 非诚勿扰 队列、(记一次失败的SBT尝试)
非诚勿扰 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) [Problem De ...
- hdu 4557 暴力
题意: 作为2013年699万应届毕业生中的一员,由于宏观经济的不景气,小明在毕业当天就华丽丽地失业了! 经历了千难万苦的求职过程,小明特别能理解毕业生的就业之难,所以,他现在准备创建一家专门针对IT ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
随机推荐
- 下载liteide
https://github.com/visualfc/liteide/releases/tag/x35.3
- flask报错No module named 'flask.ext'
解决: from flask.ext.httpauth import HTTPBasicAuth 改为 from flask_httpauth import HTTPBasicAuth 提示Modul ...
- c++ 容器元素填充指定数量的元素(generate_n)
#include <iostream> // cout #include <algorithm> // generate_n using namespace std; ; in ...
- Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR)
sudo apt-get install libsdl-dev或 sudo apt-get install libsdl1.2-dev
- shell 特殊变量详解
$0 获取当前执行脚本的名称,包括路径 [root@centos test]# cat test.sh echo $0 [root@VM_102_244_centos test]# bash test ...
- Android蓝牙通信功能开发
1. 概述 Bluetooth 是几乎现在每部手机标准配备的功能,多用于耳机 mic 等设备与手机的连接,除此之外,还可以多部手机之间建立 bluetooth 通信,本文就通过 SDK 中带的一个聊天 ...
- android调用照相机拍照获取照片并做简单剪裁
引用转载http://www.cnblogs.com/eyu8874521/archive/2012/07/20/2600697.html 效果: 客服端代码: package com.cn.lx ...
- Spring AMQP 源码分析 02 - CachingConnectionFactory
### 准备 ## 目标 了解 CachingConnectionFactory 在默认缓存模式下的工作原理 ## 前置知识 <Spring AMQP 源码分析 01 - Impatie ...
- Codeforces 847H - Load Testing
847H - Load Testing 思路:dp. 代码: #include<bits/stdc++.h> using namespace std; #define ll long lo ...
- Krapo 2
The krpano Viewer is a small and very flexible high-performance viewer for all kind of panoramic ima ...