Case of the Zeros and Ones
Description
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length n consisting of zeroes and ones. Consider the following operation: we choose any two adjacent positions in the string, and if one them contains 0, and the other contains 1, then we are allowed to remove these two digits from the string, obtaining a string of length n - 2 as a result.
Now Andreid thinks about what is the minimum length of the string that can remain after applying the described operation several times (possibly, zero)? Help him to calculate this number.
Input
First line of the input contains a single integer n (1 ≤ n ≤ 2·105), the length of the string that Andreid has.
The second line contains the string of length n consisting only from zeros and ones.
Output
Output the minimum length of the string that may remain after applying the described operations several times.
Sample Input
4
1100
0
5
01010
1
8
11101111
6
#include<iostream> using namespace std;
char a[];
int main()
{
int n,l,b=,t,c=;
cin>>n;
for(l=;l<n;l++)
{ cin>>a[l]; if(a[l]=='')
c++;
else b++;
}
if(b>c)
t=b-c;
else t=c-b;
cout<<t<<endl;
return ;
}
Case of the Zeros and Ones的更多相关文章
- Case of the Zeros and Ones 分类: CF 2015-07-24 11:05 15人阅读 评论(0) 收藏
A. Case of the Zeros and Ones time limit per test 1 second memory limit per test 256 megabytes input ...
- 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 ...
- A. Case of the Zeros and Ones----解题报告
A. Case of the Zeros and Ones Description Andrewid the Android is a galaxy-famous detective. In his ...
- Codeforces 556 A Case of the Zeros and Ones
A. Case of the Zeros and Ones time limit per test 1 second memory limit per test 256 megabytes input ...
- 找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones
题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include &l ...
- Codeforces 556A:Case of the Zeros and Ones
A. Case of the Zeros and Ones time limit per test 1 second memory limit per test 256 megabytes input ...
- Codeforces 556A Case of the Zeros and Ones(消除01)
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Andr ...
- CodeForces - 556A Case of the Zeros and Ones
//////////////////////////////////////////////////////////////////////////////////////////////////// ...
- 【52.49%】【codeforces 556A】Case of the Zeros and Ones
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
随机推荐
- android下文件下载
public static void downFile(final String url){ new Thread(){ public void run(){ FileOutputStream os= ...
- [LeetCode] Longest Substring Without Repeating Characters (LinkedHashSet的妙用)
Given a string, find the length of the longest substring without repeating characters. For example, ...
- 安卓入门学习之Hello,world!
第二章 Hello,world! 本文同时发表至简书,不为什么,用他的MarkDown在线编辑爽得要哭. 注意:本章节所使用的开发工具为Eclipse 以Android编程权威指南作为学习书物 第一节 ...
- 把Orchard部署到Windows Azure Web Sites
很久前就想做个人站点,主要用来记录自己的生活,我喜欢摄影,烘焙…然后又刚刚入皮坑,这些都可以放在网站上展示一下,或许还能为自己带来收入. 然后手上刚好有Azure的试用,于是乎动力就上来了. 以下是部 ...
- js 精美倒计时
精美倒计时*{ padding:0; margin:0;}.colockbox{width:250px;height:30px;background:url(/jscss/demoimg/201312 ...
- Week 5a - Mouse input and more lists ----mouse input
<span style="font-size:14px;">import simplegui import math # global variables ball_p ...
- [Git]自译《Git版本控制管理》——1.介绍(二)_Git诞生
译者前言: 本系列译文为作者利用业余时间翻译,有些疏漏与翻译不到位的地方敬请谅解. 不过也很希望各位读者能给出中肯的建议. 方括号的注释,如[1][2]为译者注. ...
- Node.js学习笔记1(简介)
1.什么是Node.js? Node.js,或者 Node,是一个可以让 JavaScript 运行在服务器端的平台.它可以让 JavaScript 脱离浏览器的束缚运 ...
- js基础之冒号
js中冒号的作用有两种, 转自:http://www.kqiqi.com/knowledge/web-based/506.html 一.?: 操作符 a = expression ? b : c;如果 ...
- 64位win8 配置Apache2.4+mod_msgi4.4.21+django1.8.6+python3.4
学习了很多前人分享的资料,整理如下: 安装步骤: 一.安装python3.4 下载 python-3.4.3.amd64.msi 直接安装 地址:https://www. ...