ZOJ - 3875 Lunch Time (模拟)水
来源:互联网 发布:java 制作图片 编辑:程序博客网 时间:2024/05/22 03:16
Description
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.
<h4< body="">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.
<h4< body="">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.
<h4< body="">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<h4< body="">
Sample Output
15 Fresh_Cucumber Fried_Vermicelli Steamed_Stuffed_Bun108 West_Lake_Water_Shield_Soup DongPo's_Braised_Pork DongPo's_Crisp
Hint
Source
输入三个数,分别代表三个等级的东西有多少
然后按顺序输入每个东西的名字与质量数字,然后对于每个等级选出其质量为中位数的加起来,最后输出
//思路:水题,直接模拟
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;struct node{char s[101];int val;}A[200],B[200],C[200];bool cmp(node s1,node s2){return s1.val<s2.val;}int main(){int a,b,c;int t;scanf("%d",&t);while(t--){scanf("%d%d%d",&a,&b,&c);for(int i=0;i<a;i++)scanf("%s%d",&A[i].s,&A[i].val);for(int i=0;i<b;i++)scanf("%s%d",&B[i].s,&B[i].val);for(int i=0;i<c;i++)scanf("%s%d",&C[i].s,&C[i].val);sort(A,A+a,cmp);sort(B,B+b,cmp);sort(C,C+c,cmp);int ans=0;ans=A[a/2].val+B[b/2].val+C[c/2].val;printf("%d %s %s %s\n",ans,A[a/2].s,B[b/2].s,C[c/2].s);}return 0;}
- ZOJ - 3875 Lunch Time (模拟)水
- ZOJ 3875-Lunch Time【模拟】
- ZOJ 3875 Lunch Time(水)
- zoj 3875 Lunch Time
- ZOJ 3875 Lunch Time
- ZOJ 3875 Lunch Time
- zoj Lunch Time 3875
- ZOJ - 3875-Lunch Time
- ZOJ 3875 Lunch Time(结构体排序)
- ZOJ Problem Set - 3875||Lunch Time
- ZOJ 3875 Lunch Time 排序中间值
- Lunch Time ZOJ
- ZOJ 3875 Lunch Time (The 12th Zhejiang Provincial Collegiate Programming Contest )
- zoj3875 Lunch Time(水,但有意思)
- G - Lunch Time——ZOJ
- Lunch Time
- Lunch Time
- Lunch Time
- 算法学习笔记之约瑟夫环问题
- Android学习笔记3:使用日志工具
- 《剑指offer》01 赋值运算符函数
- Android基础:动画三:属性动画
- sicily 1047(数学)
- ZOJ - 3875 Lunch Time (模拟)水
- c++写windows服务程序
- Android学习笔记4:探究活动1
- Codeforces Round 335 (Div 2) D. Lazy Student【构造 脑洞 最小生成树】
- HDOJ1203
- HBase的javaApi一个应用(创建删除表等)
- UVa 524 Prime Ring Problem
- 启动报错com/opensymphony/xwork2/spring/SpringObjectFactory.java:245:-1
- ZOJ - 3876 May Day Holiday (打表&模拟)