您的位置:首页 > 其它

joj2090

2011-08-29 09:24 232 查看




2090: Clay Bully

ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE

3s8192K414260Standard
Ms. Terry is a pre-school art teacher who likes to have her students work with clay. One of her assignments is to form a lump of clay into a block and then measure the dimensions of the block. However, in every class, there is always one child who insists
on taking some clay from some other child. Since Ms. Terry always gives every child in a class the same amount of clay to begin with, you can write a program that helps Ms. Terry find the bully and victim after she measures each child's finished block.

Input

There are one or more classes of students, followed by a final line containing only the value -1. Each class starts with a line containing an integer,
n, which is the number of students in the class, followed by n lines of student information. Each line of student information consists of three positive integers, representing the dimensions of the clay block, followed by the student's first
name. There can never be more than 9 students nor less than 2 students in any class. Each student's name is at most 8 characters. Ms. Terry always gives each student at most 250 cubic units of clay. There is exactly one bully and one victim in each class.

Output

For each class print a single line exactly as shown in the sample output.

Sample Input

3
10 10 2 Jill
5 3 10 Will
5 5 10 Bill
4
2 4 10 Cam
4 3 7 Sam
8 11 1 Graham
6 2 7 Pam
-1

Sample Output

Bill took clay from Will.
Graham took clay from Cam.


This problem is used for contest:
15

Submit /
Problem List / Status /
Discuss

Problem Set with Online Judge System Version 3.12

Jilin University

Developed by skywind,
SIYEE

#include<cstdio>

class student

{

public:

char name[10];

int volume;

};

int main()

{

student stu[10];

int n;

while(scanf("%d",&n)==1)

{

if(n==-1)break;

for(int i=0;i<n;i++)

{

int u,v,t;

scanf("%d%d%d",&u,&v,&t);

stu[i].volume=u*v*t;

getchar();

gets(stu[i].name);

}

int max=0,min=0;

for(int i=1;i<n;i++)

{

if(stu[i].volume>stu[max].volume)

{

max=i;

}

if(stu[i].volume<stu[min].volume)

{

min=i;

}

}

printf("%s took clay from %s.\n",stu[max].name,stu[min].name);

}

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: