hdu 4585 set应用
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#define Maxn 100010
using namespace std;
struct Monk{
int id,g;
int operator <(const Monk &temp) const
{
return g<temp.g;
}
};
multiset<Monk> q;
multiset<Monk> :: iterator it,it1;
int main()
{
int n,i,j,g,k,x;
Monk temp;
while(scanf("%d",&n),n)
{
q.clear();
temp.id=,temp.g=;
q.insert(temp);
for(i=;i<=n;i++)
{
scanf("%d%d",&k,&g);
temp.id=k,temp.g=g;
it=q.lower_bound(temp);
if(it==q.begin())
{
printf("%d %d\n",k,it->id);
}
else{
it1=it;
it--;
if(it1->g-g<g-it->g)
{
printf("%d %d\n",k,it1->id);
}
else
{
printf("%d %d\n",k,it->id);
}
}
q.insert(temp);
}
}
return ;
}
hdu 4585 set应用的更多相关文章
- HDU 4585 Shaolin(Treap找前驱和后继)
Shaolin Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Su ...
- HDU 4585 Shaolin(STL map)
Shaolin Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit cid= ...
- [HDU 4585] Shaolin (map应用)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4585 题目大意:不停的插入数字,问你跟他相距近的ID号.如果有两个距离相近的话选择小的那个. 用map ...
- HDU 4585
http://acm.hdu.edu.cn/showproblem.php?pid=4585 从原来的人中找出战斗数值最接近的,输出他们两人的序号 要在logn的复杂度完成查找,我用的是set,当然用 ...
- hdu 4585 Shaolin treap
Shaolin Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Problem ...
- A -- HDU 4585 Shaolin
Shaolin Time Limit: 1000 MS Memory Limit: 32768 KB 64-bit integer IO format: %I64d , %I64u Java clas ...
- hdu 4585 map **
题意: Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin temple every ...
- hdu 4585 Shaolin
原题链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=46093 #include<algorithm> #in ...
- hdu 4585 Shaolin(STL map)
Problem Description Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shao ...
随机推荐
- HDU 5623 KK's Number (博弈DP)
KK's Number 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/K Description Our lovely KK h ...
- hud 1166 敌兵布阵
http://acm.hdu.edu.cn/showproblem.php?pid=1166 敌兵布阵 Time Limit: 2000/1000 MS (Java/Others) Memory ...
- [iOS基础控件 - 6.11.5] 沙盒 & 数据存储
A.沙盒 每个APP都有一个沙盒,是独立存在的 1.Xcode5和Xcode6的模拟器文件目录 a.模拟器路径改版 (1)Xcode5中模拟器路径为:/Users/用户名/Library/Appl ...
- HDU 1394 Minimum Inversion Number (树状数组求逆序对)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1394 题目让你求一个数组,这个数组可以不断把最前面的元素移到最后,让你求其中某个数组中的逆序对最小是多 ...
- 11道php面试题
贡献11道php面试题及解决方法,跟大家总结一下曾经遇到的部分面试题.希望可以给大家得到帮助. 1. 什么事面向对象?主要特征是什么? 面象对象是把自然界的物体和概念直接映射到程序界的一种比较优雅的手 ...
- 线程暴长~Quartz中创建Redis频繁后导致线程暴长
在最近项目开发过程中,在进行任务调度处理过程中,出现了一个问题,它的线程数暴长,从20多个可以到1000多个,如果你的服务器性能好的话,可以到10000多个,太恐怖了,就算你的服务再好,早晚有一天也会 ...
- mysql case when 条件过滤
[1].[代码] 使用CASE WHEN进行字符串替换处理 跳至 [1] [2] [3] [4] ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 ...
- nginx 的安装
一.必要软件准备1.安装pcre 为了支持rewrite功能,我们需要安装pcre 复制代码代码如下: # yum install pcre* //如过你已经装了,请跳过这一步 2.安装openssl ...
- linux 下httpd服务开机启动
分类: 网站搭建2011-01-07 05:52 1164人阅读 评论(0) 收藏 举报 linuxapache 我的apache安装目录在 /usr/local/apache 有2种方法可以设置开机 ...
- Android常用正则工具类
此类提供日常开发中常用的正则验证函数,比如:邮箱.手机号.电话号码.身份证号码.日期.数字.小数.URL.IP地址等.使用Pattern对象的matches方法进行整个字符匹配,调用该方法相当于: ...