ZOJ - 3875 Lunch Time

原创 2018年04月15日 22:28:16

Problem 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 a median 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.


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 contains M 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.


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

1 3 2
Fresh_Cucumber 4
Chow_Mein 5
Rice_Served_with_Duck_Leg 12
Fried_Vermicelli 7
Steamed_Dumpling 3
Steamed_Stuffed_Bun 4
2 3 1
Stir-fried_Loofah_with_Dried_Bamboo_Shoot 33
West_Lake_Water_Shield_Soup 36
DongPo’s_Braised_Pork 54
West_Lake_Fish_in_Vinegar 48
Longjing_Shrimp 188
DongPo’s_Crisp 18

Sample Output

15 Fresh_Cucumber Fried_Vermicelli Steamed_Stuffed_Bun
108 West_Lake_Water_Shield_Soup DongPo’s_Braised_Pork DongPo’s_Crisp


#include <iostream>
#include <algorithm>
using namespace std;

struct node{
    char name[100];
    int value;
bool cmp(node u,node o){
    return u.value<o.value;
int main(){
    int n,zao,zhong,wan,sum;
    while (cin >> n){
            for (int i = 0; i < zao; ++i) {
            for (int i = 0; i < zhong; ++i) {
            for (int i = 0; i < wan; ++i) {



            cout<<sum<<" "<<q.name<<" "<<w.name<<" "<<e.name<<endl;

    return 0;
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/AcmAres/article/details/79954420

ZOJ3875:Lunch Time(浙江省赛2015)

The 12th Zhejiang Provincial Collegiate Programming Contest  The 999th Zhejiang Provincial Collegi...
  • libin56842
  • libin56842
  • 2015-04-25 19:07:38
  • 2593

zoj 3875 Lunch Time

Lunch Time Time Limit: 2 Seconds      Memory Limit: 65536 KB The 999th Zhejiang Provincial ...
  • chenzhenyu123456
  • chenzhenyu123456
  • 2015-04-25 22:49:18
  • 478

Lunch Time ZOJ - 3875

求中位数 //leehaoze #include #include #include #include #include #include #include #include #inc...
  • lee_haoze
  • lee_haoze
  • 2017-04-16 20:31:00
  • 67

zoj Lunch Time 3875

  • u014360070
  • u014360070
  • 2016-06-08 16:11:34
  • 131

ZOJ 3875 Lunch Time

题意:有三种菜的种类,挑出每种菜价格为中位数的菜,求出这三个菜的价格之和,输出这个值与三个菜名 链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do...
  • luminous11
  • luminous11
  • 2015-05-11 21:19:50
  • 257

ZOJ 3875 Lunch Time(水)

思路:水题... #include using namespace std; int T; struct node { char name[1005]; int w; }no...
  • qq_21057881
  • qq_21057881
  • 2016-04-13 10:04:23
  • 146

ZOJ 3875 Lunch Time(结构体排序)

Lunch Time Time Limit: 2 Seconds      Memory Limit: 65536 KB The 999th Zhejiang Provincial Colle...
  • 2016-04-03 11:00:21
  • 458

zoj3875 Lunch Time(水,但有意思)

为什么一道水题能给我成就感呢?大概是因为越来越会玩结构体了 #include #include #include #include #include using namespace std;...
  • Flynn_curry
  • Flynn_curry
  • 2016-03-08 19:28:03
  • 343

ZOJ - 3875 Lunch Time (模拟)水

ZOJ - 3875 Lunch Time Time Limit:                                                        2...
  • yanghui07216
  • yanghui07216
  • 2016-05-01 15:50:10
  • 161

ACM刷题之ZOJ————Lunch Time

Lunch Time Time Limit: 2 Seconds      Memory Limit: 65536 KB The 999th Zhejiang Provincial Col...
  • xiaofeng187
  • xiaofeng187
  • 2017-04-16 19:45:26
  • 346
您举报文章:ZOJ - 3875 Lunch Time