Lunch Time
来源:互联网 发布:硕士论文淘宝代写 编辑:程序博客网 时间:2024/04/30 21:11
The 999th Zhejiang Provincial Collegiate Programming Contest will be held in Marjar University. The canteen of Marjar University is making preparations for this grand competition. The canteen provides a lunch set of three types: appetizer, main course and dessert. Each type has several dishes with different prices for choosing.
Edward is the headmaster of Marjar University. One day, to inspect the quality of dishes, he go to the canteen and decides to choose amedian set for his lunch. That means he must choose one dish from each of appetizers, main courses and desserts. Each chosen dish should at the median price among all dishes of the same type.
For example, if there are five dessert dishes selling at the price of 2, 3, 5, 10, 30, Edward should choose the dish with price 5 as his dessert since its price is located at the median place of the dessert type. If the number of dishes of a type is even, Edward will choose the dish which is more expensive among the two medians.
You are given the list of all dishes, please write a program to help Edward decide which dishes he should choose.
Input
There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:
The first line contains three integers S, M and D (1 <=S, M, D <= 100), which means that there are S dishes of appetizer, M dishes of main course and D dishes of dessert.
Then followed by three parts. The first part contains S lines, the second and the last part containsM and D lines respectively. In each line of the three parts, there is a string and an integer indicating the name and the price of a dish. The name of dishes will only consist of non-whitespace characters with no more than 50 characters. The price of dishes are non-negative integers less than or equal to 1000. All dish names will be distinct.
Output
For each test case, output the total price of the median set, together with the names of appetizer, main course and dessert, separated by a single space.
Sample Input
21 3 2Fresh_Cucumber 4Chow_Mein 5Rice_Served_with_Duck_Leg 12Fried_Vermicelli 7Steamed_Dumpling 3Steamed_Stuffed_Bun 42 3 1Stir-fried_Loofah_with_Dried_Bamboo_Shoot 33West_Lake_Water_Shield_Soup 36DongPo's_Braised_Pork 54West_Lake_Fish_in_Vinegar 48Longjing_Shrimp 188DongPo's_Crisp 18
Sample Output
15 Fresh_Cucumber Fried_Vermicelli Steamed_Stuffed_Bun108 West_Lake_Water_Shield_Soup DongPo's_Braised_Pork DongPo's_Crisp
#include<iostream>#include<stdio.h>#include<string>#include<algorithm>using namespace std;struct DISH{int price;string name;};int cmp(DISH a,DISH b){return a.price<b.price;}int main(){DISH s[110],m[110],d[110];int i,T,n,count,S,M,D,sum;while(cin>>T){while(T--){sum=0;cin>>S>>M>>D; for(i=0;i<S;i++)cin>>s[i].name>>s[i].price; for(i=0;i<M;i++) cin>>m[i].name>>m[i].price; for(i=0;i<D;i++) cin>>d[i].name>>d[i].price; sort(s,s+S,cmp); sort(m,m+M,cmp); sort(d,d+D,cmp); sum=s[(S)/2].price+m[(M)/2].price+d[(D)/2].price; cout<<sum<<" "<<s[(S)/2].name<<" "<<m[(M)/2].name<<" "<<d[(D)/2].name<<endl; }}return 0;}
- Lunch Time
- Lunch Time
- Lunch Time
- hdu 4807 Lunch Time
- HDU 4807 Lunch Time
- hdu 4807 Lunch Time
- lunch time food
- zoj 3875 Lunch Time
- ZOJ 3875 Lunch Time
- ZOJ 3875 Lunch Time
- ACM-水题 Lunch Time
- zoj Lunch Time 3875
- ZOJ - 3875-Lunch Time
- Lunch Time ZOJ
- 浙江省赛 G.Lunch Time
- ZOJ 3875-Lunch Time【模拟】
- [HDOJ 4807] Lunch Time [费用流]
- ZOJ3875:Lunch Time(浙江省赛2015)
- 查看 SELinux状态及关闭SELinux
- Win7安装ant
- Aerospike C客户端手册———用户定义函数—注册用户定义函数
- 2015年大一下第6周项目2-Time类中的运算符重载
- Dijkstra 单源最短路径
- Lunch Time
- ViewSub
- Oracle 中的 TO_DATE 和 TO_CHAR 函数 日期处理
- HDU 1301Jungle Roads Kruskal求解
- CentOS常用到的查看系统命令
- Android Action Bar 详解篇
- window 下安装 mongodb
- 霍夫变换详解
- java中的可见性修饰符