https://code.google.com/codejam/contest/6224486/dashboard#s=p0

肯定把朋友们都设置在第0位,在第i位前面必须至少有i个人鼓掌,所以答案加上i-sum[i-1]即可(sum是从第0位开始到第i-1位结束包括朋友的总人数)

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=1e4;
int n;
int sum[maxn];
char buf[maxn]; int main(){
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
int T;
scanf("%d",&T);
for(int ti=1;ti<=T;ti++){
scanf("%d%s",&n,buf);
memset(sum,0,sizeof(sum));
int ans=0;
sum[0]=buf[0]-'0';
for(int i=1;i<=n;i++){
if(sum[i-1]<i){
ans+=i-sum[i-1];
sum[i-1]=i;
}
sum[i]=sum[i-1]+buf[i]-'0';
}
printf("Case #%d: %d\n",ti,ans);
}
return 0;
}

GCJ 2015-Qualification-A Standing Ovation 难度:0的更多相关文章

  1. Google Code jam Qualification Round 2015 --- Problem A. Standing Ovation

    Problem A. Standing Ovation Problem's Link:   https://code.google.com/codejam/contest/6224486/dashbo ...

  2. [C++]Standing Ovation——Google Code Jam 2015 Qualification Round

    Problem It’s opening night at the opera, and your friend is the prima donna (the lead female singer) ...

  3. [C++]Infinite House of Pancakes——Google Code Jam 2015 Qualification Round

    Problem It’s opening night at the opera, and your friend is the prima donna (the lead female singer) ...

  4. Visual Studio 2015速递(1)——C#6.0新特性怎么用

    系列文章 Visual Studio 2015速递(1)——C#6.0新特性怎么用 Visual Studio 2015速递(2)——提升效率和质量(VS2015核心竞争力) Visual Studi ...

  5. hdu 4771 13 杭州 现场 B - Stealing Harry Potter's Precious 暴力bfs 难度:0

    Description Harry Potter has some precious. For example, his invisible robe, his wand and his owl. W ...

  6. LeetCode 6 ZigZag Conversion 模拟 难度:0

    https://leetcode.com/problems/zigzag-conversion/ The string "PAYPALISHIRING" is written in ...

  7. LeetCode 201 Bitwise AND of Numbers Range 位运算 难度:0

    https://leetcode.com/problems/bitwise-and-of-numbers-range/ [n,m]区间的合取总值就是n,m对齐后前面一段相同的数位的值 比如 5:101 ...

  8. LeetCode 2 Add Two Numbers 模拟,读题 难度:0

    https://leetcode.com/problems/add-two-numbers/ You are given two linked lists representing two non-n ...

  9. Leetcode 1 two sum 难度:0

    https://leetcode.com/problems/two-sum/ class Solution { public: vector<int> twoSum(vector<i ...

随机推荐

  1. Windows_cmd_命令

    1. netstat -ano  查看端口占用情况 netstat -anp // 命令来查看一下,Linux系统是否在监听 3306 这个端口号 2.

  2. ASP.NET MVC HtmlHelper用法集锦

    ASP.NET MVC HtmlHelper用法集锦 在写一个编辑数据的页面时,我们通常会写如下代码 1:<inputtype="text"value='<%=View ...

  3. Python学习(17)异常处理

    目录 Python 异常处理 Python 标准异常 异常处理 使用except而不带任何异常类型 使用except而带多种异常类型 try-finally 语句 异常参数 异常的参数 用户自定义参数 ...

  4. linux install sublime_text3

    ubuntu & debian: (baidu or google) 1). download ***.deb to install inux系统下怎么安装.deb文件? deb 是 ubun ...

  5. 题目:在泛型为Integer的容器内添加一个字符串.

    这个题目有两种解法,第一种利用反射来解决: //ArrayList<Integer> list = new ArrayList<Integer>(); //在这个泛型为Inte ...

  6. Android开发面试经——3.常见Java基础笔试题

      Android开发(29)  版权声明:本文为寻梦-finddreams原创文章,请关注:http://blog.csdn.net/finddreams 关注finddreams博客:http:/ ...

  7. 使用Java编写一个简单的Web的监控系统cpu利用率,cpu温度,总内存大小

    原文:http://www.jb51.net/article/75002.htm 这篇文章主要介绍了使用Java编写一个简单的Web的监控系统的例子,并且将重要信息转为XML通过网页前端显示,非常之实 ...

  8. 在Linux下运行C语言程序

    市面上常见的Linux都是发行版本,典型的Linux发行版包含了Linux内核.桌面环境和各种常用的必备工具,国内使用较多的是Ubuntu(乌班图).CentOS.Deepin(深度Linux).本教 ...

  9. Winform_播放声音文件

    1.调用非托管的dll using System.Runtime.InteropServices;  //DllImport命名空间的引用 class test  //提示音 { [DllImport ...

  10. js 删除多个相同name元素。

    var obj = document.getElementsByName("abc"); for(var i = 0;i<(obj.length) * 2;i++){ obj ...