2014
03-06

# Find the hotel

Summer again! Flynn is ready for another tour around. Since the tour would take three or more days, it is important to find a hotel that meets for a reasonable price and gets as near as possible!
But there are so many of them! Flynn gets tired to look for any. It’s your time now! Given the <pi, di> for a hotel hi, where pi stands for the price and di is the distance from the destination of this tour, you are going to find those hotels, that either with a lower price or lower distance. Consider hotel h1, if there is a hotel hi, with both lower price and lower distance, we would discard h1. To be more specific, you are going to find those hotels, where no other has both lower price and distance than it. And the comparison is strict.

There are some cases. Process to the end of file.
Each case begin with N (1 <= N <= 10000), the number of the hotel.
The next N line gives the (pi, di) for the i-th hotel.
The number will be non-negative and less than 10000.

There are some cases. Process to the end of file.
Each case begin with N (1 <= N <= 10000), the number of the hotel.
The next N line gives the (pi, di) for the i-th hotel.
The number will be non-negative and less than 10000.

3
15 10
10 15
8 9

1
8 9

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;

const int MAXN = 10010;
struct Node
{
int p,d;
}node[MAXN];
bool cmp(Node a,Node b)
{
if(a.p != b.p)return a.p < b.p;
else return a.d < b.d;
}
bool f[MAXN];
int main()
{
int n;
while(scanf("%d",&n) == 1)
{
for(int i = 0;i < n;i++)
scanf("%d%d",&node[i].p,&node[i].d);
sort(node,node+n,cmp);
int Min = 100000000;
int tmp = 100000000;
int cnt = 0;
for(int i = 0;i < n;i++)
{
if(i > 0 && node[i].p != node[i-1].p)
{
Min = min(Min,tmp);
tmp = 100000000;
}
tmp = min(tmp,node[i].d);
if(Min < node[i].d)f[i] = false;
else{f[i] = true; cnt++;}
}
printf("%d\n",cnt);
for(int i = 0;i < n;i++)
if(f[i])
printf("%d %d\n",node[i].p,node[i].d);
}
return 0;
}

1. 我在东北零下20+，就是衬衫+毛衣+大衣，对了一定要有一条围巾，然后就不会很冷，还有要告诉你的一个秘密是，东北人也是在屋子里睡觉的，我们也不会整天在室外待着，然后就是室内的温度至少20+

2. 我在东北零下20+，就是衬衫+毛衣+大衣，对了一定要有一条围巾，然后就不会很冷，还有要告诉你的一个秘密是，东北人也是在屋子里睡觉的，我们也不会整天在室外待着，然后就是室内的温度至少20+

3. 我在东北零下20+，就是衬衫+毛衣+大衣，对了一定要有一条围巾，然后就不会很冷，还有要告诉你的一个秘密是，东北人也是在屋子里睡觉的，我们也不会整天在室外待着，然后就是室内的温度至少20+

4. 我在东北零下20+，就是衬衫+毛衣+大衣，对了一定要有一条围巾，然后就不会很冷，还有要告诉你的一个秘密是，东北人也是在屋子里睡觉的，我们也不会整天在室外待着，然后就是室内的温度至少20+

5. 我在东北零下20+，就是衬衫+毛衣+大衣，对了一定要有一条围巾，然后就不会很冷，还有要告诉你的一个秘密是，东北人也是在屋子里睡觉的，我们也不会整天在室外待着，然后就是室内的温度至少20+

6. 我在东北零下20+，就是衬衫+毛衣+大衣，对了一定要有一条围巾，然后就不会很冷，还有要告诉你的一个秘密是，东北人也是在屋子里睡觉的，我们也不会整天在室外待着，然后就是室内的温度至少20+

7. 站长好。我是一个准备创业的互联网小白,我们打算做一个有关国*际*游*学的平台。手上也有了一些境外资源。现阶段的团队现在没有cto.原意出让一些管理股寻找一个靠谱的技术专家做合伙人, 不知道是不是能得到您的帮助。发个帖子或者其他方式。期待您的回应。可以加我微信tianxielemon聊聊。

8. 您没有考虑 树的根节点是负数的情况， 若树的根节点是个很大的负数，那么就要考虑过不过另外一边子树了