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 5531 Rebuild (2015长春现场赛,计算几何+三分法)
Rebuild Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total S ...
- POJ 1064 Cable master (二分答案)
题目链接:http://poj.org/problem?id=1064 有n条绳子,长度分别是Li.问你要是从中切出m条长度相同的绳子,问你这m条绳子每条最长是多少. 二分答案,尤其注意精度问题.我觉 ...
- 12 为何使用Html5+CSS3
一:大多浏览器支持,低版本也没问题 我看点这方面的资料,是为了做手机应用网站(有三个方案,这个是备用方案),可以开发响应式网站,可以脱离开发平台进行跨平台. 在Html5网页中引入Modernizr, ...
- DotNetZip封装类
DotnetZip是一个开源类库,支持.NET的任何语言,可很方便的创建,读取,和更新zip文件.而且还可以使用在.NETCompact Framework中. 下载地址在这里: http://d ...
- Angularjs 初始化框架
bindJQuery(); publishExternalAPI(angular); jqLite(document).ready(function() { angularInit(document, ...
- Spring和Hibernate集成的HibernateTemplate的一些常用方法总结
1:get/load存取单条数据 public Teacher getTeacherById(Long id) { return (Teacher)this.hibernateTemplate.get ...
- Web项目的三层架构和MVC架构异同
http://www.cnblogs.com/zhhh/archive/2011/06/10/2077519.html 又看到有人在问三层架构和MVC的关系,感觉这种问题有点教条化了.因为它们都在逻辑 ...
- C# 创建移动应用
打开VS2013 选择ASP.NET MVC4Web应用程序,点击[确定] 选择[移动应用程序]点击[确定],运行之后显示的效果如图
- MySQL安装详解(V5.5 For Windows)
前言 这几年一直在用MySQL,并且是Windows+.Net+MySQL的搭配,用MyISAM引擎支持过单表每天千万以上的数据递增,TB级的数据MySQL游刃有余.最近在做一个较大并发的项目,尝试了 ...
- BZOJ 2588: Spoj 10628. Count on a tree 树上跑主席树
2588: Spoj 10628. Count on a tree Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/J ...