CodeForces 733 A.Grasshopper And the String(水~)
来源:互联网 发布:kali linux切换到root 编辑:程序博客网 时间:2024/05/22 01:50
Description
给出一个长度为n的字符串,从0开始跳过这个字符串到n+1位置,除最后一步每步只能跳到元音字母,最小化跳跃距离的最大值
Input
一个长度不超过100的只有大写字母组成的字符串
Output
最小化后的跳跃距离最大值
Sample Input
ABABBBACFEYUKOTT
Sample Output
4
Solution
扫一遍得到相邻两个元音之间最大值,再用0到第一个元音的距离以及最后一个元音到n+1的距离更新下最大值即为答案
Code
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<queue>#include<map>#include<set>#include<ctime>using namespace std;typedef long long ll;#define INF 0x3f3f3f3f#define maxn 111char s[maxn];bool check(char c){ if(c=='A'||c=='E'||c=='I'||c=='O'||c=='U'||c=='Y')return 1; return 0;}int main(){ while(~scanf("%s",s+1)) { int n=strlen(s+1); int ans=1,pre=0; for(int i=1;i<=n;i++) if(check(s[i])) { ans=max(ans,i-pre); pre=i; } ans=max(ans,n+1-pre); printf("%d\n",ans); } return 0;}
0 0
- CodeForces 733 A.Grasshopper And the String(水~)
- Codeforces 733A Grasshopper And the String
- codeforces--733A. Grasshopper And the String
- CodeForces 733A - Grasshopper And the String
- Codeforces 733A Grasshopper And the String
- CodeForces 733A Grasshopper And the String(水题)
- 【非常高%】【codeforces 733A】Grasshopper And the String
- 733A Grasshopper And the String codeforces(水题)
- 【codeforces】Grasshopper And the String(div2A)
- CodeForces 733A Grasshopper And the String(蚂蚱跳字符)
- 733A Grasshopper And the String
- A. Grasshopper And the String
- A. Grasshopper And the String
- Codeforces Round #378 (Div. 2)A. Grasshopper And the String
- Codeforces Round #378 (Div. 2) A. Grasshopper And the String
- codeforces#378 Div.2 A. Grasshopper And the String
- [codeforces] A. Grasshopper And the String 简单模拟
- codeforces 733A 733B之Grasshopper And the String Parade
- MySQL Online DDL(二)(r11笔记第88天)
- php实现邮件群发
- Error:Error: Found item Attr/duration more than one time
- 哈弗曼树
- 理解redis高可用方案
- CodeForces 733 A.Grasshopper And the String(水~)
- 微信 js 点击下载APP
- SNMPv3的加密和认证过程
- 优雅地使用Retrofit+RxJava(二)
- 485、CAN和以太网的经验理解。
- hystrix--服务隔离与熔断框架介绍
- JDBC入门
- 微信公众号及小程序开发使用weui无效解决方法
- 动图演示:Excel 50个逆天功能,逼格秒升