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的更多相关文章
随机推荐
- 【Codeforces 1137C】Museums Tour
Codeforces 1137 C 题意:给一个有向图,一周有\(d\)天,每一个点在每一周的某些时刻会开放,现在可以在这个图上从\(1\)号点开始随意地走,问最多能走到多少个开放的点.一个点如果重复 ...
- ubuntu下修改网卡名称
Ubuntu下把网卡eth0修改为eth1的步骤: 1.打开配置文件 /etc/udev/rules.d/70-persistent-net.rules,文件内容如下: # This file was ...
- git 用法---成功添加一个文件到github
一.git 提交 全部文件 git add . git add xx命令可以将xx文件添加到暂存区,如果有很多改动可以通过 git add -A .来一次添加所有改变的文件.注意 -A 选项后面还有一 ...
- RocketMQ环境搭建
1 源码下载 wget http://mirror.bit.edu.cn/apache/rocketmq/4.2.0/rocketmq-all-4.2.0-bin-release.zip unzip ...
- 腾讯云 ubuntu 上tomcat加载项目很慢
问题原因 随机数引起线程阻塞. tomcat不断启动,关闭, 启动关闭.几次后会出现卡死状况.需很久才能加载完成 阿里云同样配置,同样系统,则很难出现卡死状况. 即使出现过几十秒后也会释放出来. 而 ...
- OpenBLAS简介及在Windows7 VS2013上源码的编译过程
OpenBLAS(Open Basic Linear Algebra Subprograms)是开源的基本线性代数子程序库,是一个优化的高性能多核BLAS库,主要包括矩阵与矩阵.矩阵与向量.向量与向量 ...
- ORA-12638:Credential retrieval failed(身份证明检索失败)解决方法
版本:oracle 11g 解决方法: 在sqlnet.ora中设置SQLNET.AUTHENTICATION_SERVICES= 0.本人亲自验证,可以解决此问题. 网上说设置SQLNET.AUTH ...
- LVM : 快照
LVM 机制还提供了对 LV 做快照的功能,也就是说可以给文件系统做一个备份,这也是设计 LVM 快照的主要目的.LVM 的快照功能采用写时复制技术(Copy-On-Write,COW),这比传统的备 ...
- Nginx挂载维护页或返回自定义响应信息
在服务停机升级或者服务暂不可用时,往往希望能够返回给用户更为明确和友好的响应信息.可以通过修改nginx配置文件,达到返回自定义信息的效果.有如下几种配置方式: (1)Nginx接收到的所有请求,都返 ...
- Hexo+Github搭建博客问题
搭建过程如下: http://www.cnblogs.com/fengxiongZz/p/7707568.html 问题:第6步,发布上传代码一直不成功(没异常,也没成功). 解决:修改_ ...