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 nmk (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. 【Codeforces 1137B】Camp Schedule

    Codeforces 1137 B 题意:给两个串\(S\).\(T\),问将\(S\)中字符任意调换后出现\(T\)次数最多的方案. 思路:我们首先考虑怎么样放\(T\)才是最优的.我们直观上考虑前 ...

  2. 完整卸载 kUbuntu-desktop from Ubuntu 14.04 LTS系统 ubuntu14.04 LTS 64Bit

    sudo apt-get remove libkde3support4 k3b-data ntrack-module-libnl-0 libkrosscore4 libgpgme++2 libqapt ...

  3. arcgis_js_api_3.12的project实践

    esri.config.defaults.geometryService = new esri.tasks.GeometryService("http://localhost:6080/ar ...

  4. eclipse的快捷键【转载】

    原文地址http://www.open-open.com/bbs/view/1320934157953/ Eclipse中10个最有用的快捷键组合  一个Eclipse骨灰级开发者总结了他认为最有用但 ...

  5. Hive 创建表

    创建表的三种方式: 方式一:新建表结构 CREATE TABLE emp( empno int, ename string ) ROW FORMAT DELIMITED FIELDS TERMINAT ...

  6. python3 installed 安装 pip3

    curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python3

  7. mysql 多主

    原理:多个msyql/mariadb之间可以实时同步,任意节点的操作可以立即同步到其他节点,底层采用galera插件同步,类似rsync,上层mysql相对于galera是透明的,可以实现多节点同时读 ...

  8. java注解XML

    用的是jdk自带的javax.xml.bind.JAXBContext将对象和xml字符串进行相互转换. 比较常用的几个: @XmlRootElement:根节点 @XmlAttribute:该属性作 ...

  9. 如何新增一个ssh-key文件

    前言 由于在公司有一个sshkey 在用,用于绑定公司的git code 仓库.那么在家要连上git hub 仓库,就也需要一个 ssh key .为了避免公司信息外露,所以还是新增一个ssh key ...

  10. C_数据结构_链式二叉树

    # include <stdio.h> # include <malloc.h> struct BTNode { int data; struct BTNode * pLchi ...