I selected small hotels
Problem Description
I go to Tianjin Wanla small, along the way, he happened with his classmates many interesting things.
In the evening, the little I told his classmates to choose a hotel stay. But let all kinds of small hotels I know what to do.
For a hotel, there are many features, such as "price", "comfort." I have a little of each feature has a satisfaction.
I would choose a little higher hotel satisfaction.
Among them, "price" for small I is the most important, followed by "comfort."
If there are two hotels, the same as if "price" of satisfaction, then selected according to the "comfort"; If more hotel condition, the output of the minimum number of hotels.
Small I is now in dire straits, as they face a bunch of hotels at a loss, he thought the program would you, if you do not help him elected, he might sleep on the streets QAQ ~
Can you help him find most satisfying small hotel I do in accordance with his wishes?
Input
Multiple sets of inputs, each input for:
- Gives the n (n <= 5000) n represents a hotel (numbers 1 - n), then there are n rows of data.
- Each row of data there are two integers, representing small I of the "price", the degree of satisfaction "comfort", the higher the value the greater the degree of satisfaction, satisfaction range from 0--5000.
Output
Output according to the conditions described in the most satisfactory hotel small I number, if there are a plurality of conditions the same hotel, a hotel in the lowest numbered output.
Sample Input
4 0 1 1 0 1 1 1 0
Sample Output
3
Hint
Source
1 #include <stdio.h> 2 #include <stdlib.h> 3 struct hotel { 4 int x; 5 int y; 6 }a[5000]; 7 int main() 8 { 9 int i,n; 10 while(~scanf("%d",&n)) 11 { 12 int max=0,temp=0; 13 for (i=0;i<n;i++) 14 { 15 scanf("%d %d",&a[i].x,&a[i].y); 16 if (a[i].x==max) 17 { 18 if (a[i].y>a[temp].y) temp=i; 19 } 20 else 21 { 22 if (a[i].x>max) 23 { 24 max=a[i].x;temp=i; 25 } 26 } 27 } 28 printf("%d\n",temp+1); 29 } 30 return 0; 31 }