UVALive 6650 Falling Ants

题目链接

 

 1 #include <cstdio>
 2 #include <algorithm>
 3 using namespace std;
 4 
 5 struct Ant{
 6     int l,w,h;
 7     int v;
 8 }ant[105];
 9 
10 bool cmp(const Ant &a,const Ant &b)
11 {
12     if(a.h==b.h)
13         return a.v>b.v;
14     return a.h>b.h;
15 }
16 
17 int main()
18 {
19     int t,l,w,h;
20     while(~scanf("%d",&t)&&t)
21     {
22         for(int i=0;i<t;i++)
23         {
24             scanf("%d%d%d",&l,&w,&h);
25             ant[i].l=l; ant[i].w=w; ant[i].h=h;
26             ant[i].v=l*w*h;
27         }
28         sort(ant,ant+t,cmp);
29         printf("%d\n",ant[0].v);
30     }
31 }

 

posted @ 2016-08-31 16:26  Cumulonimbus  阅读(158)  评论(0编辑  收藏  举报