HDU 4585 Shaolin (map)
2015-06-04 20:11
489 查看
题意:
思路:
思路:
#include<cstdio> #include<iostream> #include<cstring> #include<cmath> #include<stdlib.h> #include<vector> #include<queue> #include<stack> #include<map> #include<algorithm> using namespace std; map<int,int> a; const int INF=1000000000; int main() { int n; while(scanf("%d",&n) && n) { a.clear(); a[INF]=1; for(int i=0;i<n;i++) { int id,x; scanf("%d %d",&id,&x); printf("%d ",id); map<int,int>::iterator index=a.lower_bound(x); int res1=index->first; int res2=index->second; if(index!=a.begin()) { index--; if(x-index->first <= res1-x) printf("%d\n",index->second); else printf("%d\n",res2); } else printf("%d\n",res2); a[x]=id; } } return 0; }
相关文章推荐
- Arduino学习笔记之Arduino的数字输出&串口输入
- WebKit中的智能指针(-)Raw pointers,RefPtr,PassRefPtr 一般使用方法
- CSS的选择器
- 常用jstl标签案例
- 计算机视觉、图像处理一些先进研究机构
- web前端性能优化
- HDU 4576 Robot (概率DP)
- Python 视频文件的分割和合并
- C#操作XML小结
- hdn2049(错排加组合) 递推超时问题!!!!
- (4)集合和字典
- JNI学习
- 第三章四十四题
- 满满一水壶的寻常事
- 修改.htaccess实现301重定向的几种例子
- jQuery validate 校验
- 第三章四十五题
- 海马汽车经销商管理系统技术解析(十八)修改出库
- Tomcat 6 —— Realm域管理
- 几个一