代码:
#include<cstdio> #include<algorithm> using namespace std; struct Node { char s[20]; int in[3]; int out[3]; }; int cmp1(Node a,Node b) { if(a.in[0]==b.in[0]&&a.in[1]==b.in[1]) { return a.in[2]<b.in[2]; } else if(a.in[0]==b.in[0]) { return a.in[1]<b.in[1]; } else { return a.in[0]<b.in[0]; } } int cmp2(Node a,Node b) { if(a.out[0]==b.out[0]&&a.out[1]==b.out[1]) { return a.out[2]>b.out[2]; } else if(a.out[0]==b.out[0]) { return a.out[1]>b.out[1]; } else { return a.out[0]>b.out[0]; } } Node a[100000]; int main() { int n; while(scanf("%d",&n)==1) { for(int i=0;i<n;i++) { scanf("%s",a[i].s); scanf("%d:%d:%d",&a[i].in[0],&a[i].in[1],&a[i].in[2]); scanf("%d:%d:%d",&a[i].out[0],&a[i].out[1],&a[i].out[2]); } sort(a,a+n,cmp1); printf("%s",a[0].s); sort(a,a+n,cmp2); printf(" %s\n",a[0].s); } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-08-01 21:22:41