A. Restaurant Tables
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them, it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person. If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input

The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant, the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order. If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output

Print the total number of people the restaurant denies service to.

Examples
Input
4 1 2
1 2 1 1
Output
0
Input
4 1 1
1 1 2 1
Output
2
Note

In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table. The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person, it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them. The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.

水题,注意顺序

#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define lowbit(x) x&(-x)
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define mem(a) (memset(a,0,sizeof(a)))
const int inf=0x3f3f3f3f;
int n,a,b,x;
int main()
{
int ans=;
int c=;
cin>>n>>a>>b;
for(int i=;i<n;i++)
{
scanf("%d",&x);
if(x==)
{
if(a!=) a--;
else if(b!=) c++,b--;
else if(c) c--;
else if(a== && b==) ans++;
}
else
{
if(b!=) b--;
else ans+=;
}
}
printf("%d\n",ans);
return ;
}

cf 828 A. Restaurant Tables的更多相关文章

  1. Codeforces828 A. Restaurant Tables

    A. Restaurant Tables time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. Codeforces Round #423 A Restaurant Tables(模拟)

    A. Restaurant Tables time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. 【Codeforces Round #423 (Div. 2) A】Restaurant Tables

    [Link]:http://codeforces.com/contest/828/problem/A [Description] 有n个组按照时间顺序来餐馆; 每个组由一个人或两个人组成; 每当有一个 ...

  4. Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals)

    题目链接:http://codeforces.com/contest/828 A. Restaurant Tables time limit per test 1 second memory limi ...

  5. http://codeforces.com/contest/828

    哇这是我打的第一场cf,第一题都wa了无数次,然后第二题差几分钟交 ,第二天一交就AC了内心是崩溃的.果然我还是太菜l.... A. Restaurant Tables time limit per ...

  6. Codeforces Round #423 (Div. 2)

    codeforces 423 A. Restaurant Tables [水题] //注意,一个人选座位的顺序,先去单人桌,没有则去空的双人桌,再没有则去有一个人坐着的双人桌.读清题意. #inclu ...

  7. cf 261B.Maxim and Restaurant

    什么什么期望的,不会! (题解http://blog.sina.com.cn/s/blog_140e100580102wj4e.html(看不懂)) #include<bits/stdc++.h ...

  8. CF memsql Start[c]UP 2.0 B

    CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...

  9. [转]Responsive Tables Demo

    本文转自:http://elvery.net/demo/responsive-tables/ A quick and dirty look at some techniques for designi ...

随机推荐

  1. Github README.md中添加图片

    1.先把图片上传到你的项目中:然后在github网站上按路径打开图片,如下打开的图片链接: 2.复制图片的地址 3.然后在README.md写上: ![这里随便写文字](你刚复制的图片路径) 注意  ...

  2. asp.net 缓存公共类

    using System; using System.Collections.Generic; using System.Text; using System.Web; using System.We ...

  3. python 工具包安装

    (1)wxPython是python的常用gui yum install wxPython (2)numpy, scipy是常用的数学处理工具包 yum install scipy

  4. Beat &#39;Em Up Game Starter Kit (横版格斗游戏) cocos2d-x游戏源代码

    浓缩精华.专注战斗! 游戏的本质是什么?界面?养成?NoNo!    游戏来源于对实战和比赛的模拟,所以它的本源就是对抗.就是战斗! 是挥洒热血的一种方式! 一个游戏最复杂最难做的是什么?UI?商城? ...

  5. 改动Android设备信息,如改动手机型号为iPhone7黄金土豪版!

    首先你的手机必需要有ROOT权限,误操作有风险需慎重 请先开启手机的USB调试,防止手机改动后无法启动时导致的无法修复 1.假设你是在手机上改动,直接使用RE文件管理器,编辑/system/build ...

  6. linux 下同步异步,堵塞非堵塞的一些想法

    补充: 发现一个更好的解释样例:同步是一件事我们从头到尾尾随着完毕.异步是别人完毕我们仅仅看结果. 堵塞是完毕一件事的过程中可能会遇到一些情况让我们等待(挂起).非堵塞就是发生这些情况时我们跨过. 比 ...

  7. less06 引入(importing)

    main.less @wp:960px; .colorsss{ color: darkgreen; } index.css .color{ color: #ff6600; } style.less / ...

  8. matlab subplot(figure)如何设置使得图像最终显示出来不一样大小

    1. 问题描述 figure subplot(1, 2, 1), imshow(A) subplot(1, 2, 2), imshow(B) 无论 A 和 B 的 size 是否一致,最终显示出来的 ...

  9. SharePoint 第一个网站

    第一个网站 1.建立一个社区门户网站首先要建一个IIS网站,并且把匿名访问勾选上,这样才能真正的访问网站. 创建网站的时候更改自己想要的端口,以便操作 这里更改网站是否启用匿名访问权限.点击是 然后保 ...

  10. jumpserver 安装python 报错

    环境centos7.5 pip3 insatll ./python-gssapi-0.6.4.tar.gz  报错 Command "python setup.py egg_info&quo ...