304336: CF828A. Restaurant Tables

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Restaurant Tables

题意翻译

## 题目描述 在一个小餐馆里,有$a$ 张单人桌和$b$ 张双人桌。 (单人桌就是只能坐一个人,双人桌是能坐两个,原文是只能容纳一人的坐的桌子和能容纳两人的坐的桌子,太长了) 可以知道的是,今天将会有$n$ 组人来,每组都是一人或两人。 如果一组只有一人,他将被安排坐在一个空的单人桌。如果不存在(空的单人桌),他将被安排坐在一个空的双人桌。如果不存在(空的双人桌),他将被安排坐在一个有一个人坐的双人桌。如果仍然不存在(一个人坐的双人桌),餐馆将拒绝为这组人服务。 如果一组有两人,他们将被安排坐在一个空的双人桌。如果不存在(空的双人桌),餐馆将拒绝为这组人服务。 你被给与了这些组按时间到来的情况。你要确定餐馆将拒绝为多少人提供服务。 ### 输入格式: 第一行包含三个整数$n$ ,$a$ 和$b$ ($1\leq n\leq2\cdot 10^5,1\leq a,b\leq 2\cdot 10^5$ ) — 将去餐馆的人的组数,单人桌的数量和双人桌的数量。 第二行包含一列数$t_1,t_2,\dots,t_n$ ($1\leq t_i\leq 2$ ) — 按时间描述的顾客情况。如果$t_i$ 等于1,说明第$i$ 组有一人,否则第$i$ 组有两人。 ### 输出格式: 输出餐馆将拒绝服务的人数。 ### 说明 在第一个样例中,第一组有一个人,它坐在一个空的单人桌上。下一组坐了一整个双人桌。第三组有一个人,坐在剩下的双人桌上的一个位置。第四组有一个人,他坐在双人桌的剩余的座位上。因此,所有顾客能被服务。 在第二个样例中,,第一组有一个人,它坐在一个空的单人桌上。下一组有一个人,坐在双人桌上的一个位置上。已经不可能坐下两个人,所以餐馆拒绝为他们(第三组的两个人)服务。第四组有一个人,他坐在双人桌的剩余的座位上。因此,该餐馆拒绝为$2$ 名顾客提供服务。 翻译贡献者UID:35700

题目描述

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.

输入输出格式

输入格式


The first line contains three integers $ n $ , $ a $ and $ b $ ( $ 1<=n<=2·10^{5} $ , $ 1<=a,b<=2·10^{5} $ ) — 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 $ t_{1},t_{2},...,t_{n} $ ( $ 1<=t_{i}<=2 $ ) — the description of clients in chronological order. If $ t_{i} $ is equal to one, then the $ i $ -th group consists of one person, otherwise the $ i $ -th group consists of two people.

输出格式


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

输入输出样例

输入样例 #1

4 1 2
1 2 1 1

输出样例 #1

0

输入样例 #2

4 1 1
1 1 2 1

输出样例 #2

2

说明

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.

Input

题意翻译

## 题目描述 在一个小餐馆里,有$a$ 张单人桌和$b$ 张双人桌。 (单人桌就是只能坐一个人,双人桌是能坐两个,原文是只能容纳一人的坐的桌子和能容纳两人的坐的桌子,太长了) 可以知道的是,今天将会有$n$ 组人来,每组都是一人或两人。 如果一组只有一人,他将被安排坐在一个空的单人桌。如果不存在(空的单人桌),他将被安排坐在一个空的双人桌。如果不存在(空的双人桌),他将被安排坐在一个有一个人坐的双人桌。如果仍然不存在(一个人坐的双人桌),餐馆将拒绝为这组人服务。 如果一组有两人,他们将被安排坐在一个空的双人桌。如果不存在(空的双人桌),餐馆将拒绝为这组人服务。 你被给与了这些组按时间到来的情况。你要确定餐馆将拒绝为多少人提供服务。 ### 输入格式: 第一行包含三个整数$n$ ,$a$ 和$b$ ($1\leq n\leq2\cdot 10^5,1\leq a,b\leq 2\cdot 10^5$ ) — 将去餐馆的人的组数,单人桌的数量和双人桌的数量。 第二行包含一列数$t_1,t_2,\dots,t_n$ ($1\leq t_i\leq 2$ ) — 按时间描述的顾客情况。如果$t_i$ 等于1,说明第$i$ 组有一人,否则第$i$ 组有两人。 ### 输出格式: 输出餐馆将拒绝服务的人数。 ### 说明 在第一个样例中,第一组有一个人,它坐在一个空的单人桌上。下一组坐了一整个双人桌。第三组有一个人,坐在剩下的双人桌上的一个位置。第四组有一个人,他坐在双人桌的剩余的座位上。因此,所有顾客能被服务。 在第二个样例中,,第一组有一个人,它坐在一个空的单人桌上。下一组有一个人,坐在双人桌上的一个位置上。已经不可能坐下两个人,所以餐馆拒绝为他们(第三组的两个人)服务。第四组有一个人,他坐在双人桌的剩余的座位上。因此,该餐馆拒绝为$2$ 名顾客提供服务。 翻译贡献者UID:35700

加入题单

算法标签: