题目传送门

 /*
模拟:这就是一道模拟水题,看到标签是贪心,还以为错了呢
题目倒是很长:)
*/
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std; const int MAXN = 2e5 + ;
const int INF = 0x3f3f3f3f;
int cnt[];
char s[MAXN]; int main(void) //Codeforces Round #297 (Div. 2) A. Vitaliy and Pie
{
int n;
while (scanf ("%d", &n) == )
{
scanf ("%s", s); int len = strlen (s);
memset (cnt, , sizeof (cnt)); int ans = ;
for (int i=; i<len; i+=)
{
cnt[s[i-]-'a']++;
if (cnt[s[i]-'A']) cnt[s[i]-'A']--;
else ans++;
} printf ("%d\n", ans);
} return ;
} /*
3
aAbB
4
aBaCaB
5
xYyXzZaZ
*/

模拟 Codeforces Round #297 (Div. 2) A. Vitaliy and Pie的更多相关文章

  1. Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题

    Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  ...

  2. Codeforces Round #297 (Div. 2)E. Anya and Cubes 折半搜索

    Codeforces Round #297 (Div. 2)E. Anya and Cubes Time Limit: 2 Sec  Memory Limit: 512 MBSubmit: xxx  ...

  3. Codeforces Round #297 (Div. 2)D. Arthur and Walls 暴力搜索

    Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec  Memory Limit: 512 MBSubmit: xxx ...

  4. Codeforces Round #297 (Div. 2)C. Ilya and Sticks 贪心

    Codeforces Round #297 (Div. 2)C. Ilya and Sticks Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  ...

  5. Codeforces Round #297 (Div. 2)B. Pasha and String 前缀和

    Codeforces Round #297 (Div. 2)B. Pasha and String Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx ...

  6. BFS Codeforces Round #297 (Div. 2) D. Arthur and Walls

    题目传送门 /* 题意:问最少替换'*'为'.',使得'.'连通的都是矩形 BFS:搜索想法很奇妙,先把'.'的入队,然后对于每个'.'八个方向寻找 在2*2的方格里,若只有一个是'*',那么它一定要 ...

  7. 贪心 Codeforces Round #297 (Div. 2) C. Ilya and Sticks

    题目传送门 /* 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 */ #include <cstdio ...

  8. 字符串处理 Codeforces Round #297 (Div. 2) B. Pasha and String

    题目传送门 /* 题意:给出m个位置,每次把[p,len-p+1]内的字符子串反转,输出最后的结果 字符串处理:朴素的方法超时,想到结果要么是反转要么没有反转,所以记录 每个转换的次数,把每次要反转的 ...

  9. 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts

    题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...

随机推荐

  1. stm32GPIO8种模式

    stm32GPIO工作模式及用途  1.浮空输入GPIO_IN_FLOATING ——浮空输入,可以做KEY识别,RX1       2.带上拉输入GPIO_IPU——IO内部上拉电阻输入       ...

  2. hdu4921 Map

    给最多10条链.每条链长度最大1000,链上每点有权值,每条链上按顺序,第i个点属于level[i]. 链上后一个点能够选的前提是前面的点都选了. 选择了一些点能够得到的分数是两部分加起来:1.所有点 ...

  3. 标准代码书写 C++ 的string类的用法总结

    相信使用过MFC编程的朋友对CString这个类的印象应该非常深刻吧?的确,MFC中的CString类使用起来真的非常的方便好用.但是如果 离开了MFC框架,还有没有这样使用起来非常方便的类呢?答案是 ...

  4. scala快速学习笔记(一):变量函数,操作符,基本类型

    为了用spark,先学下scala. 参考教程:http://meetfp.com/zh/scala-basic doc查询:http://docs.scala-lang.org 其它资料:http: ...

  5. configuration默认设置

    所以 上面的configuration的set可以省略,但是也可以自己改变设置,如下所示:

  6. Scrapy 'module' object has no attribute 'Spider'错误

    在“Scrapy入门教程”中,在创建的“dmoz_spider.py”文件中是通过 import scrapy class DmozSpider(scrapy.Spider): 的方式导入.但是用这种 ...

  7. 线程安全 对StringBuilder抛出ArrayIndexOutOfBoundsException的探究

    对StringBuilder抛出ArrayIndexOutOfBoundsException的探究 - CSDN博客 https://blog.csdn.net/liu_005/article/det ...

  8. 锁粒度 Deadlocks

    锁粒度 MySQL :: MySQL 5.7 Reference Manual :: 14.5.2.4 Locking Reads https://dev.mysql.com/doc/refman/5 ...

  9. 前端遇上Go: 静态资源增量更新的新实践

    前端遇上Go: 静态资源增量更新的新实践https://mp.weixin.qq.com/s/hCqQW1F8FngPPGZAisAWUg 前端遇上Go: 静态资源增量更新的新实践 原创: 洋河 美团 ...

  10. mongodb的安装、配置、常见问题

    一.MongoDB下载 mongodb可以在官网找到下载链接,找到合适的版本进行下载.下载地址->https://www.mongodb.com/download-center?jmp=nav# ...