水题 ZOJ 3875 Lunch Time

题目传送门

  1 /*
  2     水题:找排序找中间的价格,若有两个,选价格大的;
  3             写的是有点搓:)
  4 */
  5 #include <cstdio>
  6 #include <iostream>
  7 #include <algorithm>
  8 #include <cmath>
  9 #include <cstring>
 10 #include <string>
 11 #include <map>
 12 #include <set>
 13 #include <queue>
 14 #include <vector>
 15 using namespace std;
 16
 17 const int MAXN = 1e4 + 10;
 18 const int INF = 0x3f3f3f3f;
 19 struct S
 20 {
 21     char name[55];
 22     int p;
 23 }s[110];
 24 struct M
 25 {
 26     char name[55];
 27     int p;
 28 }m[110];
 29 struct D
 30 {
 31     char name[55];
 32     int p;
 33 }d[110];
 34
 35 bool cmp_s(S x, S y)
 36 {
 37     return x.p < y.p;
 38 }
 39
 40 bool cmp_m(M x, M y)
 41 {
 42     return x.p < y.p;
 43 }
 44
 45 bool cmp_d(D x, D y)
 46 {
 47     return x.p < y.p;
 48 }
 49
 50 int main(void)      //ZOJ 3875 Lunch Time
 51 {
 52     //freopen ("G.in", "r", stdin);
 53
 54     int t;
 55     scanf ("%d", &t);
 56     while (t--)
 57     {
 58         int a, b, c;
 59         int tot = 0, s_id, m_id, d_id;
 60
 61         scanf ("%d%d%d", &a, &b, &c);
 62         for (int i=1; i<=a; ++i)
 63         {
 64             scanf ("%s%d", &s[i].name, &s[i].p);
 65         }
 66         sort (s+1, s+1+a, cmp_s);
 67         for (int i=1; i<=b; ++i)
 68         {
 69             scanf ("%s%d", &m[i].name, &m[i].p);
 70         }
 71         sort (m+1, m+1+b, cmp_m);
 72         for (int i=1; i<=c; ++i)
 73         {
 74             scanf ("%s%d", &d[i].name, &d[i].p);
 75         }
 76         sort (d+1, d+1+c, cmp_d);
 77
 78          if (a & 1)
 79          {
 80             tot += s[(a+1)/2].p;    s_id = (a+1) / 2;
 81          }
 82          else
 83          {
 84             int l = a / 2; int r = l + 1;
 85             if (s[l].p < s[r].p)
 86             {
 87                 tot += s[r].p;  s_id = r;
 88             }
 89             else
 90             {
 91                 tot += s[l].p;  s_id = l;
 92             }
 93          }
 94          if (b & 1)
 95          {
 96             tot += m[(b+1)/2].p;    m_id = (b+1) / 2;
 97          }
 98          else
 99          {
100             int l = b / 2; int r = l + 1;
101             if (m[l].p < m[r].p)
102             {
103                 tot += m[r].p;  m_id = r;
104             }
105             else
106             {
107                 tot += m[l].p;  m_id = l;
108             }
109          }
110          if (c & 1)
111          {
112              tot += d[(c+1)/2].p;    d_id = (c+1) / 2;
113          }
114          else
115          {
116             int l = c / 2; int r = l + 1;
117             if (d[l].p < d[r].p)
118             {
119                 tot += d[r].p;  d_id = r;
120             }
121             else
122             {
123                 tot += d[l].p;  d_id = l;
124             }
125          }
126
127          printf ("%d %s %s %s\n", tot, s[s_id].name, m[m_id].name, d[d_id].name);
128     }
129
130
131     return 0;
132 }
133
134 /*
135 15 Fresh_Cucumber Fried_Vermicelli Steamed_Stuffed_Bun
136 108 West_Lake_Water_Shield_Soup DongPo‘s_Braised_Pork DongPo‘s_Crisp
137 */
时间: 2024-10-12 08:53:33

水题 ZOJ 3875 Lunch Time的相关文章

水题 ZOJ 3876 May Day Holiday

题目传送门 1 /* 2 水题:已知1928年1月1日是星期日,若是闰年加1,总天数对7取余判断就好了: 3 */ 4 #include <cstdio> 5 #include <iostream> 6 #include <algorithm> 7 #include <cmath> 8 #include <cstring> 9 #include <string> 10 #include <map> 11 #include

ZOJ 3609 Modular Inverse (水题)

Modular Inverse Time Limit: 2 Seconds      Memory Limit: 65536 KB The modular modular multiplicative inverse of an integer a modulo m is an integer x such that a-1≡x (mod m). This is equivalent to ax≡1 (mod m). Input There are multiple test cases. Th

ZOJ 3708 Density of Power Network (水题)

Density of Power Network Time Limit: 2 Seconds      Memory Limit: 65536 KB The vast power system is the most complicated man-made system and the greatest engineering innovation in the 20th century. The following diagram shows a typical 14 bus power s

2015南阳CCPC L - Huatuo&#39;s Medicine 水题

L - Huatuo's Medicine Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Huatuo was a famous doctor. He use identical bottles to carry the medicine. There are different types of medicine. Huatuo put medicines into the bottles and chain these b

sdut 2841 Bit Problem (水题)

题目 贴这个题是因为看题解有更简单的方法, 我做的时候是直接算的, 也很简单. 贴一下题解吧: 如果一个整数不等于 0,那么该整数的二进制表示中至少有一位是 1. 这个题结果可以直接输出 x - (x&(x-1)); 因为x-1 之后二进制下,就是最右边的1变成了0, 最右边的1的 右边所有的0变成了1, 不影响最左边. 我的代码: 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4

sdut 2413:n a^o7 !(第三届山东省省赛原题,水题,字符串处理)

n a^o7 ! Time Limit: 1000MS Memory limit: 65536K 题目描述 All brave and intelligent fighters, next you will step into a distinctive battleground which is full of sweet and happiness. If you want to win the battle, you must do warm-up according to my inst

杭电(hdu)2053 Switch Game 水题

Switch Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 13113    Accepted Submission(s): 7970 Problem Description There are many lamps in a line. All of them are off at first. A series of o

4.7-4.9补题+水题+高维前缀和

题目链接:51nod 1718 Cos的多项式  [数学] 题解: 2cosx=2cosx 2cos2x=(2cosx)^2-2 2cos3x=(2cosx)^3-3*(2cosx) 数归证明2cos(nx)能表示成关于2cosx的多项式,设为f(n) f(1)=x,f(2)=x^2-2(其中的x就是2cosx) 假设n=1~k时均成立(k>=3) 当n=k+1时 由cos((k+1)x)=cos(kx)cos(x)-sin(kx)sin(x) cos((k-1)x)=cos(kx)cos(x)

历年NOIP水题泛做

快noip了就乱做一下历年的noip题目咯.. noip2014 飞扬的小鸟 其实这道题并不是很难,但是就有点难搞 听说男神错了一个小时.. 就是$f_{i,j}$表示在第$i$个位置高度为$j$的时候最小点击次数 递推的话对于上升的情况只做一次,后面几次在后面再做.. #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> using namespace st