题目传送门

 /*
找规律/贪心:ans = n - 01匹配的总数,水
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std; const int MAXN = 2e5 + ;
const int INF = 0x3f3f3f3f;
char s[MAXN]; int main(void) //Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones
{
// freopen ("A.in", "r", stdin); int n;
while (scanf ("%d", &n) == )
{
scanf ("%s", s);
int cnt_0 = , cnt_1 = ;
for (int i=; i<n; ++i)
{
if (s[i] == '') cnt_0++;
else cnt_1++;
} printf ("%d\n", n - min (cnt_0, cnt_1) * );
} return ;
}

找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones的更多相关文章

  1. Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones 水题

    A. Case of the Zeros and Ones Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/con ...

  2. 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas

    题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...

  3. 构造 Codeforces Round #310 (Div. 2) B. Case of Fake Numbers

    题目传送门 /* 题意:n个数字转盘,刚开始每个转盘指向一个数字(0~n-1,逆时针排序),然后每一次转动,奇数的+1,偶数的-1,问多少次使第i个数字转盘指向i-1 构造:先求出使第1个指向0要多少 ...

  4. 数学/找规律/暴力 Codeforces Round #306 (Div. 2) C. Divisibility by Eight

    题目传送门 /* 数学/暴力:只要一个数的最后三位能被8整除,那么它就是答案:用到sprintf把数字转移成字符读入 */ #include <cstdio> #include <a ...

  5. 【找规律】Codeforces Round #392 (Div. 2) C. Unfair Poll

    C. Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  6. Codeforces Round #310 (Div. 1) B. Case of Fugitive set

    B. Case of Fugitive Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/555/p ...

  7. Codeforces Round #310 (Div. 1) C. Case of Chocolate set

    C. Case of Chocolate Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/555/ ...

  8. Codeforces Round #310 (Div. 2) B. Case of Fake Numbers 水题

    B. Case of Fake Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  9. Codeforces Round #310 (Div. 1) A. Case of Matryoshkas 水题

    C. String Manipulation 1.0 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...

随机推荐

  1. JS应用之禁止抓屏、复制、打印

    JS应用之禁止抓屏.复制.打印项目需要禁止抓屏.复制.打印的要求,复制.打印做起来可能顺手一点网上各种各样的脚本俯首皆是.但抓屏怎么禁止?PrintScreen是一个特殊的键,它是没有keyCode的 ...

  2. ==和equals的差别

    == 和 Equals 的差别 1. == 是一个运算符. 2.Equals则是string对象的方法.能够.(点)出来. 我们比較无非就是这两种 1.基本数据类型比較 2.引用对象比較 1.基本数据 ...

  3. 多媒体开发之wis-stream

    在live555的mediaServer中,已经实现RTSP-over-HTTP,但默认没有开启.如果要实现这个功能,需要调用RTSPServer::setUpTunnelingOverHTTP(), ...

  4. 【iOS系列】-UIWebView加载网页禁止左右滑动

    [iOS系列]-UIWebView加载网页禁止左右滑动 问题: 做项目时候,用UIWebView加载网页的时候,要求是和微信网页中打开的网页的效果一样,也即是只能上下滑动,不能左右滑动,也不能缩放. ...

  5. 内存充足,但是为什么hadoop3无法启动nodemanager

    [root@hadoop3 hadoop]# xloStarting namenodes on [hadoop3]上一次登录:三 12月 27 16:06:01 CST 2017pts/24 上Sta ...

  6. Spring Cloud 学习总结001-服务治理-Eureka

    学习参考:http://blog.didispace.com/Spring-Cloud%E5%9F%BA%E7%A1%80%E6%95%99%E7%A8%8B/ spring cloud由[服务注册中 ...

  7. USACO35 翻转奶牛(尺取法)

    通过这道题了解了不少有关翻转的知识呢...... 首先,我们枚举翻转的区间长度k,假设i有个按钮,按下就可以让i~i+k-1翻转,那就有两个状态,按i或不按i(因为按两次相当于没按),那就往后扫一遍, ...

  8. POJ2594 Treasure Exploratio —— 最小路径覆盖 + 传递闭包

    题目链接:https://vjudge.net/problem/POJ-2594 Treasure Exploration Time Limit: 6000MS   Memory Limit: 655 ...

  9. [TJOI2016&HEOI2016] 排序

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=4552 [算法] 首先 , 二分答案x , 将比x小的数看作1,比x大的数看作0 然后 ...

  10. AutoIT: 如何从excel中取值并判断条件?

    #include <Excel.au3> $excel = _ExcelBookAttach("Book1.xlsx" ,"FileName") ; ...