codeforces369A
Valera and Plates
Valera is a lazy student. He has m clean bowls and k clean plates.
Valera has made an eating plan for the next n days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, he needs exactly one clean plate or bowl. We know that Valera can cook only two types of dishes. He can eat dishes of the first type from bowls and dishes of the second type from either bowls or plates.
When Valera finishes eating, he leaves a dirty plate/bowl behind. His life philosophy doesn't let him eat from dirty kitchenware. So sometimes he needs to wash his plate/bowl before eating. Find the minimum number of times Valera will need to wash a plate/bowl, if he acts optimally.
Input
The first line of the input contains three integers n, m, k (1 ≤ n, m, k ≤ 1000) — the number of the planned days, the number of clean bowls and the number of clean plates.
The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 2). If ai equals one, then on day i Valera will eat a first type dish. If ai equals two, then on day iValera will eat a second type dish.
Output
Print a single integer — the minimum number of times Valera will need to wash a plate/bowl.
Examples
- 3 1 1
1 2 1
- 1
- 4 3 1
1 1 1 1
- 1
- 3 1 2
2 2 2
- 0
- 8 2 2
1 2 1 2 1 2 1 2
- 4
Note
In the first sample Valera will wash a bowl only on the third day, so the answer is one.
In the second sample, Valera will have the first type of the dish during all four days, and since there are only three bowls, he will wash a bowl exactly once.
In the third sample, Valera will have the second type of dish for all three days, and as they can be eaten from either a plate or a bowl, he will never need to wash a plate/bowl.
sol:直接按题意暴力模拟,能用盘子优先用盘子,否则用碗
- #include <bits/stdc++.h>
- using namespace std;
- typedef int ll;
- inline ll read()
- {
- ll s=;
- bool f=;
- char ch=' ';
- while(!isdigit(ch))
- {
- f|=(ch=='-'); ch=getchar();
- }
- while(isdigit(ch))
- {
- s=(s<<)+(s<<)+(ch^); ch=getchar();
- }
- return (f)?(-s):(s);
- }
- #define R(x) x=read()
- inline void write(ll x)
- {
- if(x<)
- {
- putchar('-'); x=-x;
- }
- if(x<)
- {
- putchar(x+''); return;
- }
- write(x/);
- putchar((x%)+'');
- return;
- }
- #define W(x) write(x),putchar(' ')
- #define Wl(x) write(x),putchar('\n')
- int n,m,k;
- int main()
- {
- int i,ans=;
- R(n); R(m); R(k);
- for(i=;i<=n;i++)
- {
- int oo=read();
- if(oo==)
- {
- if(m) m--;
- else ans++;
- }
- else
- {
- if(k) k--;
- else if(m) m--;
- else ans++;
- }
- }
- Wl(ans);
- return ;
- }
codeforces369A的更多相关文章
随机推荐
- vue filters过滤器
vue filters过滤器 vue.js允许我们自定义过滤器,可被使用于一些常见的文本格式化,过滤器可以用在两个地方,双花括号插值和 v-bind表达式.最常见的就是双花括号插值. 比如如下代码:{ ...
- spring,springmvc,mybatis整合ssm框架出现ORA-02289:序列不存在问题
今天整合了一个SSM项目,完了后部署到Tomcat服务器,正常启动.但是当我发送请求时,报错,,如下 报错说序列不存在,可是我明明创建了序列呀,然后我测试了一下,测试语句:select tb_user ...
- 关于原型继承中的constructor重定向的问题
上代码 function SuperType(name){ this.name = name; this.colors = ["red","blue",&quo ...
- 利用 ProtoThreads实现Arduino多线程处理(2)
转载请注明:@小五义http://www.cnblogs.com/xiaowuyiQQ群:64770604 感谢小V分享给大家的博文. 我在做产品设计的课题的时候,小五义推荐我使用Protothrea ...
- 3.0+百度地图在地图初始化的时候就弹框展示一个信息框,而不是用户点击poi时才弹出
有些时候我们会有这样的业务:当用户根据地址跳转到地图后,希望能够立即弹框展示该poi的地址信息. 实现方法: 百度地图3.0+的类BaiduMap中提供了一个方法showInfoWindow(Info ...
- STL语法——集合:set 安迪的第一个字典(Andy's First Dictionary,UVa 10815)
Description Andy, , has a dream - he wants to produce his very own dictionary. This is not an easy t ...
- SecureRandom
我们知道,Random类中实现的随机算法是伪随机,也就是有规则的随机.在进行随机时,随机算法的起源数字称为种子数(seed),在种子数的基础上进行一定的变换,从而产生需要的随机数字. 相同种子数的Ra ...
- CF1110H Modest Substrings AC自动机、DP
传送门 如果\(r-l\)比较小,可以将所有满足条件的串扔进\(AC\)自动机然后在上面DP,从前往后确定字符串的每一位. 但是\(l,r \leq 10^{800}\)就十分不可行,所以需要优化这个 ...
- Luogu P1439 【模板】最长公共子序列
又是模板题呵,但这次的难度有点增加. 先看题目第一个想到DP的经典算法,要O(n^2),然后想其它的算法. 其实我们衢州市一次联考有一题很像这题,不过还要难一点. 思想是离散化+最长不下降子序列(在这 ...
- [Oracle]数据库的Control File 取Dump后的样例
[Oracle]数据库的Control File 取Dump后的样例: 片段截取-------------------------------(size = 40, compat size = 40, ...