| 2 | #include<string.h> |
| 3 | using namespace std; |
| 4 | int main( ) |
| 5 | { |
| 6 | int n;//total number of the restaurants |
| 7 | cin>>n; |
| 8 | int arr[n];//array to store the points given to restaurants |
| 9 | string name[n];//array to store the names of restaurants |
| 10 | cin>>name[0] >>arr[0];//entering the first restaurant name and its point |
| 11 | int max=arr[0]; |
| 12 | string x= name[0]; |
| 13 | for(int i=1;i<n;i++) |
| 14 | { |
| 15 | cin>>name[i] >>arr[i]; |
| 16 | /*if the points is greater than max then max will be assigned this new value and thus restaurant name will be changed*/ |
| 17 | if(arr[i]>max) |
| 18 | { |
| 19 | max=arr[i]; |
| 20 | x=name[i]; |
| 21 | } |
| 22 | /*if the point is equal to max then lexicographically smallest name will be considered*/ |
| 23 | if(arr[i]==max) |
| 24 | { |
| 25 | if(x.compare(name[i])>0) |
| 26 | x=name[i]; |
| 27 | } |
| 28 | } |
| 29 | cout<<x; |
| 30 | |
| 31 | return 0; |
| 32 | } |
nothing calls this directly
no outgoing calls
no test coverage detected