• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

Codeforce Round #216 Div2 A

A. Valera and Plates
time limit per test 1 second
memory limit per test 256 megabytes
 

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 i Valera will eat a second type dish.

Output

Print a single integer — the minimum number of times Valera will need to wash a plate/bowl.

Sample test(s)
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.

 1 #include <cstdio>
 2 #include <iostream>
 3 #include <vector>
 4 #include <set>
 5 #include <cstring>
 6 #include <string>
 7 #include <map>
 8 #include <cmath>
 9 #include <ctime>
10 #include <algorithm>
11 #include <queue>
12 
13 using namespace std;
14 #define INF 0x7fffffff
15 #define maxm 1001
16 #define mod 1000000007
17 #define mp make_pair
18 #define pb push_back
19 #define rep(i,n) for(int i = 0; i < (n); i++)
20 #define re return
21 #define fi first
22 #define se second
23 #define sz(x) ((int) (x).size())
24 #define all(x) (x).begin(), (x).end()
25 #define sqr(x) ((x) * (x))
26 #define sqrt(x) sqrt(abs(x))
27 #define y0 y3487465
28 #define y1 y8687969
29 #define fill(x,y) memset(x,y,sizeof(x))
30 
31 typedef vector<int> vi;
32 typedef long long ll;
33 typedef long double ld;
34 typedef double D;
35 typedef pair<int, int> ii;
36 typedef vector<ii> vii;
37 typedef vector<string> vs;
38 typedef vector<vi> vvi;
39 
40 template<class T> T abs(T x) { re x > 0 ? x : -x; }
41 
42 const int maxn = 100015;
43 
44 int n, m, t, k,x;
45 int a[maxn],b[maxn];
46 char s[maxn];
47 
48 int main(){
49     scanf("%d%d%d", &n, &m, &k);
50     int i;
51     for (i = 0; i < n; i++){
52         scanf("%d", &a[i]);
53     }
54     t = 0; x = 0;
55     int ans=0;
56     for (i = 0; i < n; i++){
57         if (a[i] == 1){if (t < m)t++; else ans++;}
58         else {
59             if (x < k)x++;
60             else {
61                 if (t < m)t++;
62                 else ans++;
63             }
64         }
65     }
66     printf("%d\n", ans);
67     return 0;
68 }
View Code
posted @ 2013-11-30 12:24  HaibaraAi  阅读(140)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3