1.题目描述:
A.速度牛排(红色)
成绩 | 0 | 开启时间 | 2017年05月14日 Sunday 09:30 |
折扣 | 0.8 | 折扣时间 | 2017年05月12日 Friday 19:50 |
允许迟交 | 是 | 关闭时间 | 2017年05月14日 Sunday 15:00 |
题目描述
食宝街有一家叫“速度牛排”的牛排店,lx很喜欢去那里吃饭。速度牛排有5种肉质选择,按价格从小到大排序依次为:M2,M4,M6,M8,M10。
某一天lx和小伙伴一起去吃牛排,其中有n个人普通有钱,会选择价格不超过M6的牛排,有m个人超级有钱,对价格没有任何限制。
当天速度牛排有k份牛排,问最少还要做多少份牛排才能让lx和小伙伴们所有人都吃上牛排?
输入
第一行包含一个整数,表示用例组数。
每个用例第一行输入三个整数k,n,m(1<=k,n,m<=10,000),接下来包含k行,每行一个字符串表示是速度牛排中的哪种牛排。
输出
每个用例输出一个整数,表示最少还要做的牛排份数。
样例输入
1
6 4 2
M2
M4
M6
M8
M10
M8
样例输出
1
3.解题思路:
如果是2、4、6贪心地给普通人就好了
4.AC代码:
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define maxn 100100
#define lson root << 1
#define rson root << 1 | 1
#define lent (t[root].r - t[root].l + 1)
#define lenl (t[lson].r - t[lson].l + 1)
#define lenr (t[rson].r - t[rson].l + 1)
#define N 1111
#define eps 1e-6
#define pi acos(-1.0)
#define e exp(1.0)
using namespace std;
const int mod = 1e9 + 7;
typedef long long ll;
typedef unsigned long long ull;
int p[5];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
long _begin_time = clock();
#endif
int t, n, m, k;
scanf("%d", &t);
while (t--)
{
scanf("%d%d%d", &k, &n, &m);
for (int i = 0; i < k; i++)
{
char ch[4];
scanf("%s", &ch);
int x = ch[1] - '0';
if (x == 2 || x == 4 || x == 6)
{
if (n > 0)
n--;
else if (m > 0)
m--;
}
else if (m > 0)
m--;
}
printf("%d\n", n + m);
}
#ifndef ONLINE_JUDGE
long _end_time = clock();
printf("time = %ld ms.", _end_time - _begin_time);
#endif
return 0;
}