POJ 1547:Clay Bully

Clay Bully
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 8349   Accepted: 4711

Description

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.

题意是老师本来给每个人的泥土是一样多的,但是有人从其他一个人那里多拿了泥土,给了每一个人泥土的体积,问谁多拿了谁的。

洪水滔天。求最大与最小。

代码:

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#pragma warning(disable:4996)
using namespace std;

int stu[15];
string name[15];

int main()
{	
	int num,i;
	while(cin>>num)
	{
		if(num==-1)
			break;
		int temp1,temp2,temp3;
		for(i=1;i<=num;i++)
		{
			cin>>temp1>>temp2>>temp3>>name[i];
			stu[i]=temp1*temp2*temp3;
		}
		int min_n=700,min_x;
		int max_n=-1,max_x;
		
		for(i=1;i<=num;i++)
		{
			if(stu[i]>max_n)
			{
				max_x=i;
				max_n=stu[i];
			}
			if(stu[i]<min_n)
			{
				min_x=i;
				min_n=stu[i];
			}
		}
		cout<<name[max_x]<<" took clay from "<<name[min_x]<<"."<<endl;
	}
	return 0;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。

posted on 2015-07-31 16:08  光速小子  阅读(244)  评论(0编辑  收藏  举报

导航