模拟 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为还需要的蜡烛数, ...
随机推荐
- Mac中Maven的安装步骤
1.下载Maven,并解压到某个目录. 2.打开terminal,输入一下命令. open .bash_profile; 3.在bash_profile中,编辑文件 内容如下. 4.保存bash_p ...
- CSS 媒体类型 总结
CSS 媒体类型 媒体类型允许你指定文件将如何在不同媒体呈现.该文件可以以不同的方式显示在屏幕上,在纸张上,或听觉浏览器等等. 媒体类型 一些CSS属性只设计了某些媒体.例如"voice-f ...
- ios状态栏的一些操作
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES; //显示 [UIApplication sharedA ...
- iOS 开发常用的调试工具
前言 最近博主临近毕业季,为了完美的写一篇毕业论文,真是:“锄禾日当午,汗滴禾下土”<—— 这句诗跟毕业我写毕业论文没任何一毛钱关系,我就是突然想吟湿了.不过博主作为网络工程专业的好青年,曾经的 ...
- ubuntu12.04配置NFS服务详解
1:安装nfs sudo apt-get install nfs-kernel-server 2:配置服务 sudo vim /etc/exports 在末尾添加 /home/jyg *(rw,syn ...
- POJ3045 Cow Acrobats —— 思维证明
题目链接:http://poj.org/problem?id=3045 Cow Acrobats Time Limit: 1000MS Memory Limit: 65536K Total Sub ...
- Spring Boot2.0之 整合Redis事务
Redis事物 Redis 事务可以一次执行多个命令, 并且带有以下两个重要的保证: 事务是一个单独的隔离操作:事务中的所有命令都会序列化.按顺序地执行.事务在执行的过程中,不会被其他客户端发送来的命 ...
- 让 SyntaxHighlighter 3.x 支持 Lua 语法着色
1. [代码]shBrushLua.js /** * SyntaxHighlighter * http://alexgorbatchev.com/SyntaxHighlighter * * Synta ...
- hive 中 Order by, Sort by ,Dristribute by,Cluster By 的作用和用法
order by order by 会对输入做全局排序,因此只有一个reducer(多个reducer无法保证全局有序) 只有一个reducer,会导致当输入规模较大时,需要较长的计算时间. set ...
- [SoapUI] Reference parameter 引用变量
Reference parameter in WADL : Endpoint : ${#Project#DomainServer} Resource : {AdvisorID} Reference p ...