Students in Railway Carriage (思维)

10分钟极速SpringBoot项目搭建:OpenClaw AI实战攻略 OpenClaw,作为一款革命性的 AI 工具,凭借其强大的智能体能力,能够在短短 10 分钟内,帮助开发者从零构建一个完整的 SpringBoot 项目,实现真正的极速开发。它不仅极大地提高了开发效率,还降低了开发门槛,让更多的开发者能够专注于业务逻辑的实现,而无需被繁琐的配置工作所困扰 阅读详情

Students in Railway Carriage

There are n

consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.

The university team for the Olympiad consists of a

student-programmers and b student-athletes. Determine the largest number of students from all a+b

students, which you can put in the railway carriage so that:

  • no student-programmer is sitting next to the student-programmer;
  • and no student-athlete is sitting next to the student-athlete.

In the other words, there should not be two consecutive (adjacent) places where two student-athletes or two student-programmers are sitting.

Consider that initially occupied seat places are occupied by jury members (who obviously are not students at all).

Input

The first line contain three integers n

, a and b (1≤n≤2⋅105, 0≤a,b≤2⋅105, a+b>0

) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes.

The second line contains a string with length n

, consisting of characters "." and "*". The dot means that the corresponding place is empty. The asterisk means that the corresponding place is occupied by the jury member.

Output

Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.

Examples
Input
5 1 1
*...*
Output
2
Input
6 2 3
*...*.
Output
4
Input
11 3 10
.*....**.*.
Output
7
Input
3 2 3
***
Output
0
Note

In the first example you can put all student, for example, in the following way: *.AB*

In the second example you can put four students, for example, in the following way: *BAB*B

In the third example you can put seven students, for example, in the following way: B*ABAB**A*B

The letter A means a student-programmer, and the letter B — student-athlete.


思路:模拟,每次先放那个数字较大的,放一个交换两个数继续放,知道遇到*停止,然后再碰到点的时候还是先放最大的

code:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(a < b)
            swap(a,b);
        while(s[i] == '.' && i < n){
            if(a > 0) ans++;
            a--;
            swap(a,b);
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}


数字IC/FPGA 秋招知识点不全面整理 阅读详情

相关推荐

vit的cam和注意力图: VIT模型的可解释性

VIT的热力图怎么画

YI_SHU_JIA的博客 1万+

Educational Codeforces Round 42 (Rated for Div. 2) B. Students in Railway Carriage题解

B. Students in Railway Carriage consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of a student-programm...

Hacker_Wind的博客 350

[南大ICS-PA2]PA2 - 简单复杂的机器:冯诺依曼计算机系统

mips32和riscv32的指令长度只有32位, 因此它们不能像x86那样, 把C代码中的32位常数直接编码到一条指令中. 思考一下, mips32和riscv32应该如何解决这个问题?加载立即数到寄存器的高20位,然后便可以是哟给你标准的立即指令来创建32位常量。在程序分析领域中,静态指令是指程序代码中的指令,动态指令是指程序运行过程中的指令,例如对于一下指令序列。位域,在小端机器上,先定义的在每个字节的低位,后定义的在每个字节的高位。,这是处理非法指令的宏,其定义在。指令,而下一条动态指令则是。

qq_42474104的博客 928

962B Students in Railway Carriage

B. Students in Railway Carriage time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are nn consecutive

memory_qianxiao的博客 489

【课程设计】TCP/IP 应用环境中服务器的部署与实现

本项目旨在通过搭建一个虚拟网络环境,实现软路由系统的配置和服务器的搭建与测试。具体包括安装虚拟机 VMWare Workstation,安装 Windows Server 2003 操作系统,配置软路由系统(包括双网卡安装、协议配置和测试),以及搭建并测试 DHCP 服务、DNS 服务、WWW 服务、FTP 服务和 SMTP/POP3 服务。

weixin_74907236的博客 1524

Cisco Firepower FMCv修改管理Ip方法

Cisco Firepower FMCv修改管理Ip方法

funnycoffee123的博客 1091

Educational Codeforces Round 42 (Rated for Div. 2)-B. Students in Railway Carriage

B. Students in Railway Carriagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn consecutive seat places in a railway carriage. Each pl...

PinesL 380

手把手教你为RV1126开发板点亮3寸MIPI屏(ST7701S驱动,含设备树配置避坑点)

本文详细介绍了RV1126开发板适配3寸MIPI屏幕(ST7701S驱动)的全流程,涵盖硬件设计、信号完整性保障、屏幕时序参数计算及设备树配置等关键步骤。特别针对MIPI差分信号布线、电压匹配和设备树配置中的常见问题提供了实用解决方案,帮助开发者高效完成屏幕适配工作。

weixin_42524703的博客 329

Codeforces Educational Codeforces Round 42 (Rated for Div. 2) B. Students in Railway Carriage 填放人数

点击打开链接#include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;cstring&gt; using namespace std; typedef long long LL; const int maxn=2*1e5+5; char s[maxn]; int main() { int n,a,b; scanf("%d...

老铁,干了这碗algorithms的博客 337

【无人机基站】基于K-mean算法实现无人机基站部署附matlab代码

【无人机基站】基于K-mean算法实现无人机基站部署附matlab代码

天天酷科研的博客 239

《YOLO11改进有效涨点》 专栏目录 | 目前已有100+篇内容,内含各种Head检测头、损失函数Loss、Backbone、Neck等创新点改进【持续更新】

YOLO11改进专栏目录,YOLO11改进目录

kay_545 1万+

Students in Railway Carriage

链接:http://codeforces.com/problemset/problem/962/B B. Students in Railway Carriage time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output...

weixin_43890535的博客 217

手把手教你学Simulink--基于飞轮储能系统的场景实例:飞轮储能与锂电池混合储能系统的协同控制

本文详细介绍了基于Simulink的飞轮储能与锂电池混合储能系统协同控制建模方法。通过高通/低通滤波器实现功率分配,使飞轮处理高频波动(±100kW),锂电池承担削峰填谷(50kW)。仿真结果表明,该系统效率达88%,锂电池循环次数减少90%,投资成本比纯电池方案节省200万美元。文章包含完整的建模步骤、控制策略设计和多场景仿真分析,为构建高效、长寿、经济的智能储能系统提供了实用解决方案。

MHD0815的博客 341

codeforces 962B. Students in Railway Carriage

题目链接:http://codeforces.com/problemset/problem/962/BB. Students in Railway Carriagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn con...

Amo丶 415

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

H - Students in Railway Carriage

There are nn consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger. The university team for the Olympiad consists of aa student-programmers and bb stude...

XYBDX的博客 237

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Students in Railway Carriage,

    题目大致意思,一个由'*'和'.'组成的长度为N的字符串,现在有a个A和b个B去顶替其中的'.',不能有两个A相邻或B相邻的情况,问最后一共可以放几个A和B。    Example:inputCopy5 1 1 *...* outputCopy2    上手开始暴力求解......(这一段没有算法思想而且冗长,觉得没有意义就跳过吧)#include&lt;stdio.h&gt; #incl...

Pleaseinput的博客 317

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

CodeForces 962B Students in Railway Carriage

          题意是输入n,a,b,表示有n个字符,a个A,b个B,字符串中'.'表示空位,A B不能相连,问最多能放多少个A和B。AC代码:#include &lt;iostream&gt; #include &lt;cstdio&gt; #include &lt;cstring&gt; using namespace std; int n,a,b; char str[200005]; ...

Charles_Zaqdt的博客 915

codeforces贪心 B. Students in Railway Carriage

B. Students in Railway Carriage time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output There are n consecutive seat places in a railway carr...

qq_36386435的博客 373

codeforces 962 B. Students in Railway Carriage

B. Students in Railway Carriagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn consecutive seat places in a railway carriage. Each pl...

howell 293

codeforce round42-B

B. Students in Railway Carriagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn consecutive seat places in a railway carriage. Each pl...

Swust_ZzK的博客 297

Educational Codeforces Round 42(4.11)

A. Equator Polycarp has created his own training plan to prepare for the programming contests. He will train for nn days, all days are numbered from 11 to nn, beginning from the first. On the ii-th ...

反之亦然 511

Educational Codeforces Round 42 (Rated for Div. 2)

A. Equatortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp has created his own training plan to prepare for the programming contests. He w...

loving coding 337

[UVA11895]Honorary Tickets

https://vjudge.net/problem/UVA-11895 Chief of AUT ICPC public relations offers an honorary visit to AUT ICPC site to lucky winners. It includes acknowledging former members Agha Hadi, smile2ka1...

C20172809的博客 605

Educational Codeforces Round 42 BCD

好久没做cf,四道题读错2道你敢信- -B. Students in Railway Carriagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn consecutive seat places in a railw...

K键盘里的青春K 346

codeforces 962-B. Students in Railway Carriage(暴力+贪心)

http://codeforces.com/problemset/problem/962/B 题目大意: 一辆列车上有n个座位,但是有些座位放了东西不能够坐。现在有A类和B类数人,给他们安排座位,并且A类的人不能喝B类的人直接相邻坐,计算最多能够坐多少人。 解题思路: 枚举每个放了东西不能做的点,将两个放了东西不能坐的点之间区间值保存到vec数组中,然后贪心安排A和B...

HJ 510

Codeforces Educational Round #42

CF962A Equator(模拟) CF962B Students in Railway Carriage(贪心) CF962C Make a Square(爆搜) CF962D Merge Equals(stl) CF962E Byteland, Berland and Disputed Cities(贪心)

Icefox的博客 421
上一篇: DNA sequence HDU - 1560 (IDA*)
下一篇: FatMouse's Speed (贪心+最长严格符合条件子序列DP+路径还原)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值