【CodeForces】426Div2 B The Festive Evening
来源:互联网 发布:美国大选重新计票 知乎 编辑:程序博客网 时间:2024/06/04 19:57
链接:http://codeforces.com/contest/834/problem/B
Solution
暴力计算一下每个时刻有多少门开启就好
注意不要先关门再判断
#include<stdio.h>#define N 1000005int n,k,tot;bool vis[26],st[N],ed[N];char s[N];int main(){ scanf("%d%d",&n,&k); scanf("%s",s+1); for (int i=1;i<=n;i++) if (!vis[s[i]-'A']) vis[s[i]-'A']=1,st[i]=1; for (int i=0;i<26;i++) vis[i]=0; for (int i=n;i;i--) if (!vis[s[i]-'A']) vis[s[i]-'A']=1,ed[i]=1; for (int i=1;i<=n;i++) { if (k<(tot+=st[i])) { puts("YES"); return 0; } tot-=ed[i]; } puts("NO");}
阅读全文
0 0
- 【CodeForces】426Div2 B The Festive Evening
- CodeForces #426 div2 B The Festive Evening
- B. The Festive Evening(Codeforces Round #426 (Div. 2) B)
- Codeforces Round #426 (Div. 2) B. The Festive Evening
- Codeforces Round #426 (Div. 2)-B. The Festive Evening
- Codeforces Round #426 (Div. 2) B The Festive Evening
- (模拟)Codeforces Round #426 B. The Festive Evening
- Codeforces Round #426 (Div. 2) B. The Festive Evening
- Codeforces Round #426 (Div. 2) B. The Festive Evening
- Codeforces Round #426 (Div. 2)B. The Festive Evening
- Codeforces 834B-The Festive Evening
- Codeforces Round 834B-The Festive Evening
- Codeforces 834 B The Festive Evening
- CodeForces 834B The Festive Evening
- The Festive Evening (Codeforces
- #426 (Div. 2) B. The Festive Evening
- CodeForces 834 B.The Festive Evening(水~)
- Codeforces Round #426 (Div. 2) B.The Festive Evening+C.The Meaningless Game
- mybatis对时间段查询以及转义字符
- java SimpleDateFormat线程安全
- day_06_拷贝构造、拷贝赋值、静态成员
- 集合框架——Map集合
- 轻量级文本代码编辑工具
- 【CodeForces】426Div2 B The Festive Evening
- Codeforces Round 834B-The Festive Evening
- 【机器学习PAI实践十二】机器学习算法基于信用卡消费记录做信用评分
- NYOJ 364 田忌赛马
- linux学习笔记(9)
- ABAP的子程序参数注意点
- PowerDesigner,根据name自动生成commnet的脚本
- Opencv Mat属性
- 数组去重