joj2090

 2090: Clay Bully


Result TIME Limit MEMORY Limit Run Times AC Times JUDGE
3s 8192K 421 266 Standard

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

 
 
 
 1 #include <stdio.h>
2
3 int main(void)
4 {
5 //freopen("in.txt", "r", stdin);
6
7 int a, b, c;
8 int min, max;
9 int t[10]; //存体积
10 int sample;
11 char s[10][10]; //存名字
12 int i;
13
14 int t1, t2;
15
16 while (scanf("%d", &sample)==1, sample!=-1)
17 {
18
19 for (i=0; i<sample; i++)
20 {
21 scanf("%d%d%d", &a, &b, &c);
22 t[i] = a*b*c;
23 scanf("%s", &s[i]);
24 }
25
26 max = min = t[0];
27 for (i=1; i<sample; i++)
28 {
29 if (max < t[i])
30 {
31 max = t[i];
32 t2 = i;
33 }
34 if (min > t[i])
35 {
36 min = t[i];
37 t1 = i;
38 }
39 }
40
41 printf("%s took clay from %s.\n", s[t2], s[t1]);
42 }
43
44 return 0;
45 }

你可能感兴趣的:(OJ)