4349: The Tallest in the Class
Description
We want to know who is the tallest student in our class. But student’s height is used a different unit of measurement, either
metres(m), decimeteres(dm), centimetres(cm), or millimetres(mm).
Your job is to find out the names of the tallest student in our class.
Input
There are multiple cases.
The first line of each case is an integer n, 0
#include<iostream>
#include<map>
#include<string>
#include<cmath>
using namespace std;
int main(){
int t;
while(~scanf("%d",&t)){
map<string,double>m;
double ma=0;
while(t--){
double d;
string s,c;
cin>>s>>d>>c;
if(c=="cm")
d*=10;
else if("dm"==c)
d*=100;
else if("m"==c)
d*=1000;
if(m[s]!=0)
s="#"+s;
m[s]=d;
if(ma<d)ma=d;
}
map<string,double>::iterator it;
for(it=m.begin();it!=m.end();it++){
if(fabs(it->second-ma)<1e-7){
string str=it->first;
if(str[0]=='#')
str.erase(0,1);
cout<<str<<endl; }
}
cout<<endl;
}
return 0;
}