Valera and Plates

CodeForces - 369A

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

Input
3 1 1
1 2 1
Output
1
Input
4 3 1
1 1 1 1
Output
1
Input
3 1 2
2 2 2
Output
0
Input
8 2 2
1 2 1 2 1 2 1 2
Output
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的更多相关文章

随机推荐

  1. css3渐变特性

    项目中,一般用于业务办理的进度条,设置背景色,纯背景色可以直接设置,如果是渐变色,那使用line-gradient渐变特性就需要设置渐变的位置了入下图 方法一.直接在进度条轨道上面再加一个元素,用于设 ...

  2. MySQL 基础八 用户管理

    SELECT * FROM student INSERT INTO student(NAME,sex,createuser,createtime) VALUES('jack','男','ligenyu ...

  3. XD308H设计超宽电压非隔离电源 MP150电源芯片

    220V转12V 220V转24V 380V转5V 3800V转12V 380V转24V 参考:https://wenku.baidu.com/view/862c19fca0c7aa00b52acfc ...

  4. ubuntu 下使用 jsoncpp库

    做项目的时候需要用c++解析json文件, 之前使用的是libjson 库, 但当g++ 开启 -std=c++11 选项时, 该库的很多功能不能用, 而且还有一些其他的问题, 不推荐使用. 后来采用 ...

  5. Android学习之基础知识一

    一.Android的系统架构: 1.Linux内核层:提供Android硬件的各种驱动(显示驱动,音频驱动,蓝牙驱动,WiFi驱动等等) 2.系统运行库层:提供各种特性支持(数据库支持,绘图支持,浏览 ...

  6. Quartz的JobDetail没有触发器指向时会被删除的问题

    之前项目里使用的是老版本的Quartz,才1.6.5.发现一个问题,如果我触发器配置的时间已经过了,想去手动触发一个任务,就会报找不到这个任务的异常,通过debug可以发现,Scheduler里添加j ...

  7. SkylineGlobe 6.6 开放的事件函数接口

    SkylineGlobe 6.6 开放的事件函数接口: struct __declspec(uuid("84ce9e1b-65ad-11d5-85c1-0001023952c1") ...

  8. Android popupMenu

    popupMenu = new PopupMenu(ActivityHousesNumList.this, imageViewhousesnum1); popupMenu.getMenuInflate ...

  9. spring boot + dubbo开发遇到过的异常

    异常信息 NoClassDefFoundErrororg.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1162) Sessio ...

  10. webpack 构建 node_modules 中公司内部组件

    构建 node_modules 中特定的组件 { test:/\.js$/, exclude: /node_modules\/(?!(zt-)\/).*/, use:[ { loader:" ...