标签:
2 2 2000 30 123456789 2000 20 987654321 4 3000 50 872198442 3000 45 752498124 2000 60 765128742 3000 45 652278122
987654321 752498124
1 #include<stdio.h> 2 #include<algorithm> 3 using namespace std; 4 struct d 5 { 6 int m,n; 7 int l; 8 }; 9 d num[1001]; 10 bool cmp(d m,d n) 11 { 12 return m.m>n.m; 13 } 14 int main() 15 { 16 int m; 17 scanf("%d",&m); 18 while(m--) 19 { 20 int i,n; 21 scanf("%d",&n); 22 for(i=0;i<n;i++) 23 { scanf("%d %d %d",&num[i].m,&num[i].n,&num[i].l); } 24 sort(num,num+n,cmp); 25 26 int length=num[0].m,min=num[0].m,temp=0; 27 for(i=0;i<n;i++) 28 { 29 if(num[i].m==length&&num[i].n<min) 30 { 31 min=num[i].n; 32 temp=i; 33 } 34 } 35 36 int max=num[temp].l,bijiao=num[temp].n; 37 for(i=0;i<n;i++) 38 { 39 if(num[i].m==length&&num[i].n==bijiao&&num[i].l>max) 40 max=num[i].l; 41 } 42 printf("%d\n",max); 43 } 44 return 0; 45 }
标签:
原文地址:http://www.cnblogs.com/fengshun/p/4560861.html