304534: CF864B. Polycarp and Letters

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Polycarp and Letters

题意翻译

题意: 已知一个只包含大写字母和小写字母的字符串s.现在有这样一个集合:它可以包含字符串中不同小写字母的位置,但是这些位置中任意两个之间不能有大写字母.现在请你写一个程序求集合最大时的大小. 输入: 第一行一个整数n(1<=n<=200),表示字符串的长度 第二行一个字符串s 输出: 这个集合最大时的大小 Translated by 凌幽

题目描述

Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string $ s $ consisting only of lowercase and uppercase Latin letters. Let $ A $ be a set of positions in the string. Let's call it pretty if following conditions are met: - letters on positions from $ A $ in the string are all distinct and lowercase; - there are no uppercase letters in the string which are situated between positions from $ A $ (i.e. there is no such $ j $ that $ s[j] $ is an uppercase letter, and $ a_{1}<j<a_{2} $ for some $ a_{1} $ and $ a_{2} $ from $ A $ ). Write a program that will determine the maximum number of elements in a pretty set of positions.

输入输出格式

输入格式


The first line contains a single integer $ n $ ( $ 1<=n<=200 $ ) — length of string $ s $ . The second line contains a string $ s $ consisting of lowercase and uppercase Latin letters.

输出格式


Print maximum number of elements in pretty set of positions for string $ s $ .

输入输出样例

输入样例 #1

11
aaaaBaabAbA

输出样例 #1

2

输入样例 #2

12
zACaAbbaazzC

输出样例 #2

3

输入样例 #3

3
ABC

输出样例 #3

0

说明

In the first example the desired positions might be $ 6 $ and $ 8 $ or $ 7 $ and $ 8 $ . Positions $ 6 $ and $ 7 $ contain letters 'a', position $ 8 $ contains letter 'b'. The pair of positions $ 1 $ and $ 8 $ is not suitable because there is an uppercase letter 'B' between these position. In the second example desired positions can be $ 7 $ , $ 8 $ and $ 11 $ . There are other ways to choose pretty set consisting of three elements. In the third example the given string $ s $ does not contain any lowercase letters, so the answer is $ 0 $ .

Input

题意翻译

题意: 已知一个只包含大写字母和小写字母的字符串s.现在有这样一个集合:它可以包含字符串中不同小写字母的位置,但是这些位置中任意两个之间不能有大写字母.现在请你写一个程序求集合最大时的大小. 输入: 第一行一个整数n(1<=n<=200),表示字符串的长度 第二行一个字符串s 输出: 这个集合最大时的大小 Translated by 凌幽

加入题单

上一题 下一题 算法标签: