CF828A.Restaurant Tables

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

一家小餐馆有 aa 张单人桌和 bb 张双人桌。

已知今天共有 nn 个顾客团体依次到来,每个团体由一人或两人组成。

  • 若一个团体由一人组成,则优先安排至一张空闲的单人桌;若没有空闲单人桌,则安排至一张空闲的双人桌;若也没有空闲双人桌,则安排至一张已有单人就座的双人桌(即与该单人同坐);若仍无法安排,则该团体被拒之门外。
  • 若一个团体由两人组成,则仅可安排至一张空闲的双人桌;若没有空闲双人桌,则该团体被拒之门外。

你将获得顾客团体按时间顺序到来的列表。请计算该餐馆总共拒绝服务的顾客人数。

输入格式

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 _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.

第一行包含三个整数 nn、aa 和 bb(1 ≤ n ≤ 2⋅1051 ≤ n ≤ 2·10^5,1 ≤ a, b ≤ 2⋅1051 ≤ a, b ≤ 2·10^5)—— 分别表示来餐厅的团体数量、单人桌数量和双人桌数量。

第二行包含一个整数序列 t1, t2, ..., tnt_1, t_2, ..., t_n(1 ≤ ti ≤ 21 ≤ t_i ≤ 2)—— 按时间顺序描述顾客。若 ti=1t_i = 1,则第 ii 个团体由一人组成;否则,第 ii 个团体由两人组成。

输出格式

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.

在第一个例子中,第一组由一人组成,他坐在一张空闲的单人桌旁;第二组占据了一张完整的双人桌;第三组由一人组成,他坐在剩余双人桌的一个座位上;第四组由一人组成,他坐在该双人桌剩余的那个座位上。因此,所有顾客均得到了服务。

在第二个例子中,第一组由一人组成,他坐在一张空闲的单人桌旁;第二组由一人组成,他坐在双人桌的一个座位上;接下来的两人组无法入座,因此餐厅拒绝为其提供服务;第四组由一人组成,他坐在该双人桌剩余的那个座位上。因此,餐厅共拒绝为 2 名顾客提供服务。

输入解题思路,AI测评打分。不知道怎么写?

首页