#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
map<int ,int>mp;
int n;
while(~scanf("%d",&n)&&n)
{
int id,fg;
mp[]=;
for(int i=; i<n; i++)
{
scanf("%d %d",&id,&fg);
mp[fg]=id;
map<int ,int>::iterator it=mp.find(fg),it1;
if(it==mp.begin())
printf("%d %d\n",id,(++it)->second);
else
{
it1=it;
if(abs((--it)->first-fg)<=abs((++it1)->first-fg))
printf("%d %d\n",id,(it)->second);
else
printf("%d %d\n",id,(it1)->second); }
}
mp.clear(); }
return ;
}

map是有序的好处

HDU4329的更多相关文章

随机推荐

  1. 直播推流之blibli和拉流LFLiveKit

    执行上面操作后,导入合成的拉流blibli包到工程中,然后新建个播放控制器来设置播放 1.  播放的一些操作. 2. 高斯模糊. 3. 新建聊天控制器. - (void)viewDidLoad { [ ...

  2. 有理数的稠密性(The rational points are dense on the number axis.)

    每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.

  3. 分享基于EF+MVC+Bootstrap的通用后台管理系统及架构

      基于EF+MVC+Bootstrap构建通用后台管理系统,集成轻量级的缓存模块.日志模块.上传缩略图模块.通用配置及服务调用, 提供了OA.CRM.CMS的原型实例,适合快速构建中小型互联网及行业 ...

  4. Html-IOS下input的样式添加不上的解决方案

    问题描述: <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml&qu ...

  5. centos 6.5 redis 安装

    安装教程有用的地址 https://my.oschina.net/u/2478188/blog/726984: 错误1 Redis: You need tcl 8.5 or newer in orde ...

  6. Redis集群(八):Redis Sharding集群

    一.Redis目前的集群方案主要有两种:Redis Sharding和Redis Cluster 1.Redis Sharding:3.0以前基本上使用分片实现集群,目前主流方案,客户端实现 2.Re ...

  7. Leetcode 18. 4Sum

    Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = tar ...

  8. 【Codeforces163E】e-Government AC自动机fail树 + DFS序 + 树状数组

    E. e-Government time limit per test:1 second memory limit per test:256 megabytes input:standard inpu ...

  9. oracleXE(oracle学习版)在windows的安装配置

    oracleXE其实安装基本就是一路下一步. 在安装前记得先把tomcat打开,不然oracleXE会占用8080端口且安装过程无法更改端口. 如果需要远程连接此oracle XE的话,要关闭这台电脑 ...

  10. Android源码——Broadcast Receiver

    Android源码分析——广播 广播是一种在组件之间进行消息传递的方式.广播机制的实现是基于Binder进程间通信. Binder进程间通信和广播的差别:Binder中,Client组件和Servic ...