B. Polycarp and Letters
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 a1 < j < a2 for some a1 and a2 from A).

Write a program that will determine the maximum number of elements in a pretty set of positions.

Input

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.

Output

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

Examples
input
11
aaaaBaabAbA
output
2
input
12
zACaAbbaazzC
output
3
input
3
ABC
output
0
Note

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.

这道题一直理解不了题意,看了代码才知道到底啥意思。

就是先找出每一段小写字母里的不同元素有多少个,再输出其中最大那一段的值。

#include<cstdio>
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<sstream>
#include<algorithm>
#include<string>
#include <cstring>
using namespace std;
const int maxn = 111;
int nu[maxn];
set<int> st;
string s;
int main() {
ios::sync_with_stdio(false);
int n;
int maxx = 0;
cin>>n>>s;
s+="A";
for(int i = 0; i <= n; i++) {
// cout<<st.size()<<endl;
if(s[i] >= 'a' && s[i] <= 'z') st.insert(s[i]);
else maxx = max(maxx,(int)st.size()),st.clear();
}
cout<<maxx<<endl;
return 0; }

  

codefoeces 864B的更多相关文章

  1. Codefoeces 734F. Anton and School 数学

    Codefoeces 734F 题目大意: 给定两个正整数序列\(b,c\)构造一个正整数序列\(a\)使其满足 \[ \left\{ \begin{array}{} b_i=(a_i\text{ a ...

  2. CodeFoeces 1215 D Ticket Game(数学,思维)

    CodeFoeces 1215 D Ticket Game 题目大意 M和B轮流玩游戏(每一轮M先手 现在给出一个长度为偶数的串,包含字符'?'和数字 现在两人依次在'?'上填数字\(0\)~\(9\ ...

  3. [Codeforces 864B]Polycarp and Letters

    Description Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s con ...

  4. codefoeces problem 671D——贪心+启发式合并+平衡树

    D. Roads in Yusland Mayor of Yusland just won the lottery and decided to spent money on something go ...

  5. codefoeces 671 problem D

    D. Roads in Yusland standard output Mayor of Yusland just won the lottery and decided to spent money ...

  6. 刷题总结——book of evil(codefoeces 337D)

    题目: description Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This ar ...

  7. codefoeces B. Friends and Presents

    B. Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input stand ...

  8. CodeFoeces GYM 101466A Gaby And Addition (字典树)

    gym 101466A Gaby And Addition 题目分析 题意: 给出n个数,找任意两个数 “相加”,求这个结果的最大值和最小值,注意此处的加法为不进位加法. 思路: 由于给出的数最多有 ...

  9. Codeforces Round #436 (Div. 2) 题解864A 864B 864C 864D 864E 864F

    A. Fair Game time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

随机推荐

  1. Sentry(v20.12.1) K8S 云原生架构探索,JavaScript 性能监控之管理 Transactions

    系列 Sentry-Go SDK 中文实践指南 一起来刷 Sentry For Go 官方文档之 Enriching Events Snuba:Sentry 新的搜索基础设施(基于 ClickHous ...

  2. APM调用链产品对比

    APM调用链产品对比 随着企业经营规模的扩大,以及对内快速诊断效率和对外SLA(服务品质协议,service-level agreement)的追求,对于业务系统的掌控度的要求越来越高,主要体现在: ...

  3. 1.5V升3.3V芯片电路图,稳压3.3V供电MCU模块等

    干电池1.5V可以升到3.3V,通过PW5100干电池升压IC,于外围3个元件:2个电容和一个电感即可组成1.5V升3.3V的电路系统. 干电池属于低能量的电池产品,不过一般使用到干电池的产品也是输出 ...

  4. windows_myql 安装与卸载详细讲解,

    windows_myql 安装 注意: 安装前把 所有杀毒软件,安全卫士等关闭. 打开下载的mysql安装文件双击解压缩,运行"mysql-5.5.40-win64.msi". 注 ...

  5. 阿里 Mock 工具正式开源,干掉市面上所有 Mock 工具!

    最近栈长注意到阿里开源了自家的 Mock 工具:TestableMock,该工具号称最轻量.简单.舒适的 Mock 测试工具,功能十分强大,媲美 PowerMock,用法比 Mockito 还要简洁, ...

  6. vue2.0、vue3.0不同之处

    一.响应式赋值操作不同 Vue2.0 1.通过data返回对象做相应: 2.对复杂的对象或数组下的属性等深层次的改变需要通过$set的方式. Vue3.0 1.ref实现简单的实现响应,通过value ...

  7. RabbitMq消费者在初始配置之后进行数据消费

    RabbitMq消费者在初始配置之后进行数据消费 问题背景 在写一个消费rabbitmq消息的程序是,发现了一个问题,消费者的业务逻辑里面依赖这一些配置信息,但是当项目启动时,如果队列里面有积压数据的 ...

  8. DP 状态 DP 转移方程 动态规划解题思路

    如何学好动态规划(2) 原创 Gene_Liu LeetCode力扣 今天 算法萌新如何学好动态规划(1) https://mp.weixin.qq.com/s/rhyUb7d8IL8UW1IosoE ...

  9. 正向代理 forward proxy、反向代理 reverse proxy、透明代理 transparent proxy

    https://zh.wikipedia.org/wiki/反向代理 反向代理在计算机网络中是代理服务器的一种.服务器根据客户端的请求,从其关系的一组或多组后端服务器(如Web服务器)上获取资源,然后 ...

  10. Canvas实现弧线时钟

    最近试着用canvas元素的2d绘图函数做了一个弧线形的时钟. 我也没啥好说的,直接上代码: <div id="myclock"></div> <sc ...