1006 Sign In and Sign Out (25 point(s))
String sorting, from small to large, from large to small twice, output.
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e3+10;
const int inf_int = 1e9;
int M;
struct node{
string a,b,c;
}t[maxn];
bool cmp1(node &N1,node &N2){
return N1.b < N2.b;
}
bool cmp2(node &N1,node &N2){
return N1.c > N2.c;
}
int main(){
while(cin>>M){
for(int i = 1;i<=M;i++){
cin>>t[i].a>>t[i].b>>t[i].c;
}
sort(t+1,t+M+1,cmp1);
cout<<t[1].a<<' ';
sort(t+1,t+M+1,cmp2);
cout<<t[1].a<<'\n';
}
return 0;
}