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. [转]Java代码(性能)优化总结

    前言 代码优化,一个很重要的课题.可能有些人觉得没用,一些细小的地方有什么好修改的,改与不改对于代码的运行效率有什么影响呢?这个问题我是这么考虑的,就像大海里面的鲸鱼一样,它吃一条小虾米有用吗?没用, ...

  2. JavaWeb学习总结(九)--JDBC入门

    一.什么是JDBC JDBC(Java DataBase Connectivity)就是Java数据库连接,说白了就是用Java语言来操作数据库.原来我们操作数据库是在控制台使用SQL语句来操作数据库 ...

  3. oracle对象类型

    Oracle的对象类型 对象类型 在PL/SQL中,面向对象的程序设计师基于对象类型来完成的.对象类型是用户自定义的一种复合数据类型,它封装了数据结构和用于操纵这些数据结构的过程和函数. 数据库的对象 ...

  4. 网络性能测试工具iperf详细使用图文教程【转载】

    原文:http://blog.163.com/hlz_2599/blog/static/142378474201341341339314/ 参考:http://man.linuxde.net/iper ...

  5. RMAN-03009 ORA-19504 ORA-27038

    错误信息如下: RMAN> backup database tag='full20160112' format '/orabak/rman/full20160112' include curre ...

  6. 串行通讯之UARTLoopback

    目录 第1章串行通讯之UARTLoopback    2 1 USB转串口    2 2 USB Accessory    2 3 连入手机    3 4 代码改进    4 5 打开串口    4 ...

  7. linux笔记:文件编辑器vim

    vim的3种工作模式: 在命令模式下进入插入模式: 定位命令: 删除命令: 复制和剪切命令: 替换和取消命令: 查找和替换命令: 保存和退出命令: 导入命令执行结果和定义快捷键:

  8. Compound Interest Calculator3.0

    Compound Interest Calculator3.0 1.利率这么低,复利计算收益都这么厉害了,如果拿100万元去买年报酬率10%的股票,若一切顺利,过多长时间,100万元就变成200万元呢 ...

  9. WMI远程访问问题解决方法

    WMI 全称为:Microsoft Windows Management Instrumentation (WMI)  按微软的介绍大致如下:      WMI 是 Microsoft 主要的针对 W ...

  10. java 三大框架 介绍

    三大框架:Struts+Hibernate+Spring Java三大框架主要用来做WEN应用. Struts主要负责表示层的显示 Spring利用它的IOC和AOP来处理控制业务(负责对数据库的操作 ...