A. Grasshopper And the String(CF ROUND 378 DIV2)

A. Grasshopper And the String

time limit per test

1 second 

memory limit per test

256 megabytes 

input

standard input 

output

standard output 

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 1 to the value of his jump ability.

The picture corresponds to the first example. 

The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.

Input

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. 

Output

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.

Examples

Input

ABABBBACFEYUKOTT 

Output

Input

AAA 

Output

1

题目链接:http://codeforces.com/contest/733/problem/A

 

题目本意是让求他最大跳跃距离(最大跳跃距离是两个元音字母直接的距离,最后一个元音字母和结尾的距离,还有一种可能就是" B " 这样的情况)

 

WA了两发,

第一发没考虑到:

A 这样的数据

第二发没考虑到

B 这样的数据

 

AC代码:

 

#include<cstdio>

#include<iostream>

#include<cmath>

#include<algorithm>

#include<cstring>

using namespace std;

 

bool vowel( char i )

{

       if(i == 'A' || i == 'E' || i== 'I' || i== 'O' || i== 'U' || i == 'Y' || i=='\0' ||i==' ' )

              returntrue ;

       returnfalse ;

}

 

int main()

{

       strings;

 

       cin>>s;

       s='' + s ;

       int_length = s.length() ;

       intmax = 1 ;

       for(int i = 0 ; i < _length ; i++)

              {

                     if(vowel( s[i] ) )

                            {

                                   for(int j = i+1; j<=_length ; j++)

                                          {

                                                 if(vowel( s[j] ) )

                                                        {

                                                               if(j - i  > max )

                                                                      max= j-i;

                                                               break;

                                                        }

                                          }

                            }

              }

       cout<< max << endl ;

       return0 ;

 

}

 

posted on 2017-01-12 23:24  Dark猫  阅读(143)  评论(0)    收藏  举报

导航