HDU 4585 Shaolin STL map 水
2014-06-24 09:10
253 查看
#include<iostream> #include<stdio.h> #include<string> #include<string.h> #include<algorithm> #include<set> #include <cstdio> #include <cstring> #include <iostream> #include <math.h> #include <queue> using namespace std; #include<map> map<int,int >m; int main() { int n; while(scanf("%d",&n),n){ int a,b; int i; m.clear(); m[1000000000]=1; // key值为1000000000 映射值:1; for(i=0;i<n;i++){ scanf("%d%d",&a,&b); printf("%d",a); map<int,int>::iterator t=m.lower_bound(b);//寻找到 b<=最近 // printf("%d %d\n",t->second,t->first); // t->second 表示映射值 // t->first 表示key值 if(t==m.end())//b为最大 { t--; printf(" %d\n",t->second); } else { int t1 = t->first; int tmp = t->second; if(t!=m.begin()) { t--; if(b-t->first<=t1-b)// b在中间 比较两端 差值 printf(" %d\n",t->second); else printf(" %d\n",tmp); } else printf(" %d\n",t->second);// b最小 } m[b]=a;// 加入 } } return 0; }
相关文章推荐
- HDU 4585 Shaolin STL map 水
- hdu 4585 Shaolin(STL map)
- HDU 4585 Shaolin(STL map)
- HDU 4585 Shaolin(STL map)
- hdu 4585 Shaolin两种方法(暴力和STL map set)
- [HDU 4585] Shaolin (map应用)
- HDU 4585 Shaolin (STL)
- hdu 4585 shaolin 平衡树
- hdu 4585 Shaolin 2013 ACM-ICPC杭州赛区全国邀请赛——题目重现
- hdu 4585 Shaolin(二分)
- hdu 4585 STL map 的运用
- HDU 4585 Shaolin 找最接近的数 Treap / set
- HDU 4585——Shaolin
- HDU 4585 Shaolin(Treap)
- hdu 4585 Shaolin
- HDU 4585 Shaolin (STL)
- Shaolin - HDU 4585 - 树堆
- HDU 4585(Shaolin-Treap的lower_bound&upper_bound操作)
- hdu 4585 shaolin 平衡树
- HDU 4585 ShaoLin 基础Treap