模拟 Codeforces Round #297 (Div. 2) A. Vitaliy and Pie
/*
模拟:这就是一道模拟水题,看到标签是贪心,还以为错了呢
题目倒是很长:)
*/
#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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- BFS Codeforces Round #297 (Div. 2) D. Arthur and Walls
题目传送门 /* 题意:问最少替换'*'为'.',使得'.'连通的都是矩形 BFS:搜索想法很奇妙,先把'.'的入队,然后对于每个'.'八个方向寻找 在2*2的方格里,若只有一个是'*',那么它一定要 ...
- 贪心 Codeforces Round #297 (Div. 2) C. Ilya and Sticks
题目传送门 /* 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 */ #include <cstdio ...
- 字符串处理 Codeforces Round #297 (Div. 2) B. Pasha and String
题目传送门 /* 题意:给出m个位置,每次把[p,len-p+1]内的字符子串反转,输出最后的结果 字符串处理:朴素的方法超时,想到结果要么是反转要么没有反转,所以记录 每个转换的次数,把每次要反转的 ...
- 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...
随机推荐
- 尝试使用UISearchDisplayController及对苹果对控件封装习惯的理解
本文转载至 http://blog.sina.com.cn/s/blog_74e9d98d01019vji.html 在之前做过的应用中,很多都有“搜索”这个功能,大部分情况下我都是只采用UISe ...
- SpringInAction4笔记——web
1,java配置 extends AbstractAnnotationConfigDispatcherServletInitializer public class SpitterWebInitial ...
- java线程阻塞(sleep,suspend,resume,yield,wait,notify)
为了解决对共享存储区的访问冲突,Java 引入了同步机制,现在让我们来考察多个线程对共享资源的访问,显然同步机制已经不够了,因为在任意时刻所要求的资源不一定已经准备好了被访问,反过来,同一时刻准备好了 ...
- xamarin.android listview绑定数据及点击事件
前言 listview是用来显示数据列表的一个控件,今天给大家带来如何使用cursor进行数据绑定以及点击事件. 导读 1.如何创建一个listview 2.如何使用cursor进行绑定数据 3.li ...
- SQL JOIN连接分类[转]
1.内联接(典型的联接运算,使用像 = 或 <> 之类的比较运算符):包括相等联接和自然联接: 内联接使用比较运算符根据每个表共有的列的值匹配两个表中的行: 2.外联接.外联接可以 ...
- bzoj3462: DZY Loves Math II
状态很差脑子不清醒了,柿子一直在推错.... ... 不难发现这个题实际上是一个完全背包 问题在于n太大了,相应的有质数的数量不会超过7个 假设要求sigema(1~plen)i pi*ci=n 的方 ...
- Scrapy运行报错:ModuleNotFoundError: No module named 'douban.douban'
运行scrapy爬虫报错: from douban.douban.items import DoubanItem ModuleNotFoundError: No module named 'douba ...
- codeforces 460B Little Dima and Equation 解题报告
题目链接:http://codeforces.com/problemset/problem/460/B 题目意思:给出a, b, c三个数,要你找出所有在 1 ≤ x ≤ 1e9 范围内满足 x = ...
- Oracle基础:表空间名称大小写问题
现场环境: 操作系统:windows Oracle版本:10g 今天在通过imp导入数据时,日志提示TS_W5_D表空间不存在.感觉很奇怪,导入用户的表空间是ts_w5_d,并 ...
- [原创]java获取word文档的条目化内容
在开发Web办公系统或文档系统时,PageOffice组件是众所周知的在线处理微软word/ppt/excel文档的强大工具,它对WORD文档的各种处理在API层面进行了封装,屏蔽了Office VB ...