题意:给定两个字符串,然后从第二个中找和第一个相同的,如果大小写相同,那么就是YAY,如果大小写不同,那就是WHOOPS。YAY要尽量多,其次WHOOPS也要尽量多。

析:这个题并不难,难在读题懂题意。首先把两个字符串的的每个字符存起来,然后,先扫一遍,把所有的能YAY的都选出来,剩下的再尽量先WHOOPS。

代码如下:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cstring>
#include <cmath>
#include <map>
#include <cctype> using namespace std;
const int maxn = 1000 + 5;
map<char, int> mp1;
map<char, int> mp2;
string s1, s2; int main(){
cin >> s1 >> s2;
for(int i = 0; i < s1.size(); ++i)
++mp1[s1[i]];
for(int i = 0; i < s2.size(); ++i)
++mp2[s2[i]]; int cnt1 = 0, cnt2 = 0;
for(int i = 0; i < 26; ++i){
if(mp1[i+'a'] >= mp2[i+'a']){
cnt1 += mp2[i+'a'];
mp1[i+'a'] -= mp2[i+'a'];
mp2[i+'a'] = 0;
}else{
cnt1 += mp1[i+'a'];
mp2[i+'a'] -= mp1[i+'a'];
mp1[i+'a'] = 0;
}
if(mp1[i+'A'] >= mp2[i+'A']){
cnt1 += mp2[i+'A'];
mp1[i+'A'] -= mp2[i+'A'];
mp2[i+'A'] = 0;
}else{
cnt1 += mp1[i+'A'];
mp2[i+'A'] -= mp1[i+'A'];
mp1[i+'A'] = 0;
}
}
for(int i = 0; i < 26; ++i){
if(mp1[i+'a']) cnt2 += min(mp1[i+'a'], mp2[i+'A']);
if(mp1[i+'A']) cnt2 += min(mp1[i+'A'], mp2[i+'a']);
}
printf("%d %d\n", cnt1, cnt2);
return 0;
}

CodeForces 518B Tanya and Postcard (题意,水题)的更多相关文章

  1. CodeForces 518B. Tanya and Postcard

    B. Tanya and Postcard time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  2. codeforces 518B. Tanya and Postcard 解题报告

    题目链接:http://codeforces.com/problemset/problem/518/B 题目意思:给出字符串 s 和 t,如果 t 中有跟 s 完全相同的字母,数量等于或者多过 s,就 ...

  3. CodeForces 682B Alyona and Mex (题意水题)

    题意:给定一个序列,你可以对这里面的数用小于它的数来代替,最后让你求,改完后的最大的序列中缺少的最小的数. 析:这个题,读了两个多小时也没读懂,要是读懂了,肯定能做出来...没什么可说的,就是尽量凑1 ...

  4. Educational Codeforces Round 7 B. The Time 水题

    B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...

  5. Educational Codeforces Round 7 A. Infinite Sequence 水题

    A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...

  6. Codeforces Testing Round #12 A. Divisibility 水题

    A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...

  7. Codeforces Beta Round #37 A. Towers 水题

    A. Towers 题目连接: http://www.codeforces.com/contest/37/problem/A Description Little Vasya has received ...

  8. codeforces 677A A. Vanya and Fence(水题)

    题目链接: A. Vanya and Fence time limit per test 1 second memory limit per test 256 megabytes input stan ...

  9. CodeForces 690C1 Brain Network (easy) (水题,判断树)

    题意:给定 n 条边,判断是不是树. 析:水题,判断是不是树,首先是有没有环,这个可以用并查集来判断,然后就是边数等于顶点数减1. 代码如下: #include <bits/stdc++.h&g ...

随机推荐

  1. Mac 使用ab性能测试工具

    Mac 使用ab命令进行压测 1.在Mac中配置Apache ①启动Apache,打开终端 sudo apachectl -v 如下显示Apache的版本 sudo apachectl start 这 ...

  2. 网站配色、网站模板网址 UE样式 metro报表

    http://www.colourlovers.com http://unmatchedstyle.com网站模板目录    花瓣 http://huaban.com/    油表 http://fl ...

  3. map、reduce处理数据结构及常见案例

    随着三大前端框架和小程序的流行,MVVM大行其道,而其中的核心是 ViewModel 层,它就像是一个中转站(value converter),负责转换 Model 中的数据对象来让数据变得更容易管理 ...

  4. Python将数据写入excel或者txt,读入csv格式或xls文件,写入csv(写一行空一行解决办法)

    1.写入excel,一开始不需要自己新建一个excel,会自动生成 attribute_proba是我写入的对象 import xlwt myexcel = xlwt.Workbook() sheet ...

  5. php soap实例讲解

    一,什么是soap,什么是wsdl,为什么要用他们 SOAP是基于XML和HTTP通信协议,xml各种平台,各种语言都支持的一个种语言.http呢它得到了所有的因特网浏览器及服务器的支持. WSDL ...

  6. Python的设计哲学

    Beautiful is better than ugly. 优美胜于丑陋 Explicit is better than implicit. 明了胜于晦涩 Simple is better than ...

  7. Bootstrap的介绍和响应式媒体查询

    Bootstrap的介绍 凡是使用过Bootstrap的开发者,都不在乎做这么两件事情:复制and粘贴.哈哈~,是的使用Bootstrap非常简单,但是在复制粘贴之前,需要先对Bootstrap的用法 ...

  8. WCF传输大数据 --断点续传(upload、download)

    using System; using System.IO; using System.Runtime.Serialization; using System.ServiceModel; namesp ...

  9. wampserver中php版本的升级

    以php5.3.10到5.4.31版本为例: 1.  停止WAMP服务器. 2.  去网站windows.php.net 下载php-5.4.31-Win32-VC9-x86.zip. 不要下载THE ...

  10. IOS上架(九) AppStore编译生成ipa文件并上传

    IOS上架上传ipa文件 AppStore https://itunesconnect.apple.com delphi project>option里的CFBundleVersion 上传的版 ...