One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1to the value of his jump ability.
![](https://i-blog.csdnimg.cn/blog_migrate/835b7b5226cbdab007e46a06897f303d.png)
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Print single integer a — the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
ABABBBACFEYUKOTT
4
AAA
某日,一只蚂蚱来到了一片字母草地。草地由n个大写字母组成。蚂蚱一开始在草地的最左边(位置0),它要去往草地的最右边(位置n+1)。这只蚂蚱只在元音字母上跳跃(起点和终点除外)。定义这只蚂蚱的跳跃能力为它一次跳跃能跳过的最远距离。
试问,若要让这只蚂蚱顺利到达终点,蚂蚱的跳跃能力最小是多少?下图是样例1的参考图:
元音字母有: 'a', 'E', 'I', 'O', 'U','Y'.
一行一个字符串s,只有大写字母,描述这个草地。长度小于 1000。
输出一个整数,表示这只蚂蚱最小跳跃能力。
ABABBBACFEYUKOTT
AAA
4
1
无
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[1010];
int main()
{
memset(a,0,sizeof(a));
while(~scanf("%s",a))
{
int b[1010]={0},c[1010]={0},d=0,k=1;
int len=strlen(a);
for(int i=0; i<len; i++)
{
if(a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U'||a[i]=='Y')
b[d++]=i;
}
c[0]=b[0]+1;
for(int i=1; i<d; i++)
c[k++]=b[i]-b[i-1];
c[k++]=len-b[d-1];
sort(c,c+k);
if(d!=0)
printf("%d\n",c[k-1]);
if(d==0)
printf("%d\n",len+1);
}
return 0;
}