PAT (Advanced Level) 1006. Sign In and Sign Out (25)
简单题。
#include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<cstdio> #include<vector> using namespace std; struct X { string name; int a,b; }s[10000]; int n,hh,mm,ss; bool cmp1(const X&a,const X&b) { return a.a<b.a; } bool cmp2(const X&a,const X&b) { return a.b>b.b; } int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { cin>>s[i].name; scanf("%d:%d:%d",&hh,&mm,&ss); s[i].a=hh*60*60+mm*60+ss; scanf("%d:%d:%d",&hh,&mm,&ss); s[i].b=hh*60*60+mm*60+ss; } sort(s+1,s+1+n,cmp1); cout<<s[1].name<<" "; sort(s+1,s+1+n,cmp2); cout<<s[1].name<<"\n"; return 0; }