ZOJ Problem Set - 1755 Clay Bully
来源:互联网 发布:淘宝店铺首页有个红包 编辑:程序博客网 时间:2024/05/20 09:25
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 <string>#include <vector>using namespace std;int main(){int n;while(cin>>n){if(n==-1)break;int *a=new int[n];std::vector<std::string> str(n);for(int i=0;i<n;i++)a[i]=1;int b=0;for(int i=0;i<n;i++){for(int j=0;j<3;j++){cin>>b;a[i]*=b;}cin>>str[i];}int count=0;for(int i=0;i<n;i++)count+=a[i];count/=n;int x,y;for(int i=0;i<n;i++){if(a[i]>count)x=i;if(a[i]<count)y=i;}cout<<str[x]<<" took clay from "<<str[y]<<"."<<endl;}return 0;}
- ZOJ Problem Set - 1755 Clay Bully
- ZOJ 1755 Clay Bully
- zoj 1755 Clay Bully
- ZOJ 1755 Clay Bully
- zoj 1755 Clay Bully
- zoj 1755 Clay Bully(水~)
- ZOJ 1755 && POJ 1547 Clay Bully(简单排序+map容器)
- pku_1547 Clay Bully
- POJ 1547 Clay Bully
- POJ 1547:Clay Bully
- Clay Bully-1547
- 北大ACM poj1547 Clay Bully
- POJ 1547 Clay Bully G++
- ZOJ Problem Set - 2060
- ZOJ Problem Set - 2972
- ZOJ Problem Set - 1037
- ZOJ Problem Set - 1048
- ZOJ Problem Set - 1049
- (二)设计模式之创建型
- Java字节码运行浅析
- redhat 5.9下开启ftp服务
- php条件语句(2)switch...case语句
- Android之-EditText不弹出输入法设置
- ZOJ Problem Set - 1755 Clay Bully
- 摩羯天蝎谁是腹黑帝
- USB OTG驱动分析(一)
- Nyoj 43 24 Point game
- 谷歌排名算法变革反思,站长觉悟吧
- ImportError: DLL load failed: %1 Ч Win32 Ӧ ó
- UITableViewCell 设置圆角
- Python 改变当前工作目录
- Mysql+Corosync+Pacemaker+DRBD