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. CSS规范之BFC & IFC

    元素是文档结构的基础,在CSS中,每个元素生成了一个包含了元素内容的框(box,也译为"盒子").但是不同的元素显示的方式会有所不同,例如<div>和<span& ...

  2. mysql 检查字符串是否包含子串

    1.使用substring_index(src,target,index) 从src的开头查找第index个target.返回的substring为从src的开头到第num个target这段字符串.比 ...

  3. 详细地jsoncpp编译方法 和 vs2010中导入第三方库的方法

    详细地jsoncpp编译方法 和 vs2010中导入第三方库的方法 一 编译链接 1 在相应官网下载jsoncpp 2 解压得到jsoncpp-src-0.5.0文件 3 打开jsoncpp-src- ...

  4. oracle查询一个数据库有几张表

    登录sys用户后通过user_tables表查看当前用户下表的张数.sql:conn / as sysdba;sql:select count(*) from user_tables ;解释:必须是登 ...

  5. haskell rust相关文章

    Combining Rust and Haskell http://tab.snarc.org/posts/haskell/2015-09-29-rust-with-haskell.html

  6. JQuery基础汇总

    1. 对象获取与赋值::$("#obj").val("Hello World!"); 2. 对象的显示与隐藏:$("#obj").show( ...

  7. 深入理解JVM虚拟机-2自动内存管理机制

    java虚拟机所管理的内存将会包括一下几个运行时数据区域. 程序计数器: 程序计数器是一块较小的内存空间.字节码解析式工作时就是通过改变这个计数器的值来选取下一条需要执行的字节码指令,分支.循环.跳转 ...

  8. Working with Data » 使用Visual Studio开发ASP.NET Core MVC and Entity Framework Core初学者教程

    原文地址:https://docs.asp.net/en/latest/data/ef-mvc/intro.html The Contoso University sample web applica ...

  9. js字符串函数之split()join()

    split方法用于把一个字符串切割成字符串数组,与join相反 一个参数表示以该参数为切割点, var str="silence's world"; console.log(str ...

  10. meta viewport 详解

    ViewPort <meta>标记用于指定用户是否可以缩放Web页面,如果可以,那么缩放到的最大和最小缩放比例是什么.使用ViewPort <meta>标记还表示文档针对移动设 ...