天天看点

B. Polycarp and Letters

s

A be a set of positions in the string. Let's call it pretty

  • A
  • A(i.e. there is no suchjthats[j] is an uppercase letter, anda1 <j<a2 for somea1 anda2 fromA).

pretty

Input

n (1 ≤ n ≤ 200) — length of string s.

s

Output

pretty set of positions for string s.

Examples

input

11

aaaaBaabAbA

output

2

input

12

zACaAbbaazzC

output

3

input

3

ABC

output

题目大概:

求连续的小写子母中,种类最多的是多少种。

代码:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int a[150];
int b[150];
char q[202];
int main()
{
    int n;
    scanf("%d\n",&n);
    for(int i=1;i<=n;i++)
    {

        scanf("%c",&q[i]);

    }
    int sum=0;
    int su=0;
        for(int i=1;i<=n;i++)
    {
        if(q[i]>='A'&&q[i]<='Z')
        {
            if(sum<su)sum=su;
            su=0;
            memset(b,0,sizeof(b));
        }
        else{
        if(!b[(int)q[i]]){b[(int)q[i]]=1;su++;}

        }

    }
    if(sum<su)sum=su;
    printf("%d",sum);

    return 0;
}