Google Code jam Qualification Round 2015 --- Problem A. Standing Ovation
Problem A. Standing Ovation
Problem's Link: https://code.google.com/codejam/contest/6224486/dashboard#s=p0
Mean:
题目说的是有许多观众,每个观众有一定的羞涩值,只有现场站起来鼓掌的人数达到该值才会站起来鼓掌,问最少添加多少羞涩值任意的人,才能使所有人都站起来鼓掌。
analyse:
贪心模拟一下,从前往后扫一遍就行。
Time complexity: O(n)
Source code:
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std; const int MAXN=;
int n;
char s[MAXN];
int main()
{
// freopen("E:\\Code_Fantasy\\C\\A-small-attempt0.txt","r",stdin);
// freopen("E:\\Code_Fantasy\\C\\A-small-attempt1.txt","w",stdout);
int t;
scanf("%d",&t);
for(int Cas=;Cas<=t;++Cas)
{
scanf("%d",&n);
scanf("%s",s);
int ans=;
int shy=s[]-'';
for(int i=;i<=n;++i)
{
if(s[i]-''!=)
{
if(shy>=i)
shy+=(s[i]-'');
else
{
ans+=(i-shy);
shy=i+(s[i]-'');
}
}
}
printf("Case #%d: %d",Cas,ans);
if(Cas!=t) puts("");
}
return ;
}
Google Code jam Qualification Round 2015 --- Problem A. Standing Ovation的更多相关文章
- dp - Google Code jam Qualification Round 2015 --- Problem B. Infinite House of Pancakes
Problem B. Infinite House of Pancakes Problem's Link: https://code.google.com/codejam/contest/6224 ...
- [C++]Store Credit——Google Code Jam Qualification Round Africa 2010
Google Code Jam Qualification Round Africa 2010 的第一题,很简单. Problem You receive a credit C at a local ...
- Google Code Jam 2010 Round 1C Problem A. Rope Intranet
Google Code Jam 2010 Round 1C Problem A. Rope Intranet https://code.google.com/codejam/contest/61910 ...
- [Google Code Jam (Qualification Round 2014) ] B. Cookie Clicker Alpha
Problem B. Cookie Clicker Alpha Introduction Cookie Clicker is a Javascript game by Orteil, where ...
- [Google Code Jam (Qualification Round 2014) ] A. Magic Trick
Problem A. Magic Trick Small input6 points You have solved this input set. Note: To advance to the ...
- [C++]Saving the Universe——Google Code Jam Qualification Round 2008
Google Code Jam 2008 资格赛的第一题:Saving the Universe. 问题描述如下: Problem The urban legend goes that if you ...
- Google Code Jam 2010 Round 1C Problem B. Load Testing
https://code.google.com/codejam/contest/619102/dashboard#s=p1&a=1 Problem Now that you have won ...
- Google Code Jam 2010 Round 1A Problem A. Rotate
https://code.google.com/codejam/contest/544101/dashboard#s=p0 Problem In the exciting game of Jo ...
- Google Code Jam 2010 Round 1B Problem B. Picking Up Chicks
https://code.google.com/codejam/contest/635101/dashboard#s=p1 Problem A flock of chickens are runn ...
随机推荐
- H5长按事件
let timeOutEvent = 0 $(function () { $('#debug').on({ touchstart: function (e) { setTimeout(function ...
- ecshop 进入后台登录帐号出现乱码解决方法
进入后台登录帐号出现如果生成乱码 MySQL server error report:Array ( [0] => Array ( [message] => MySQL Query Err ...
- 随机抽样一致性算法(RANSAC)示例及源代码
作者:王先荣 大约在两年前翻译了<随机抽样一致性算法RANSAC>,在文章的最后承诺写该算法的C#示例程序.可惜光阴似箭,转眼许久才写出来,实在抱歉.本文将使用随机抽样一致性算法来来检测直 ...
- Solved: Qt Library LNK 2001 staticMetaObject error
在链接Qt的库,比如QtGui4.lib,我这里是在链接QtSolutions_PropertyBrowser-head.lib的时候出现的链接错误.大概是说一个"XXXX::s ...
- Embeding Python & Extending Python with FFPython
Introduction ffpython is a C++ lib, which is to simplify tasks that embed Python and extend Python. ...
- typeof instanceof 之间的区别总结
typeof 它返回值是一个字符串,该字符串说明运算数的类型. a=1; b=true; c="c"; d=function(){ console.log(" ...
- 2015 Android Dev Summit(安卓开发峰会)第一天
今年的Google I/O没有抽到票,不能到现场参加.不过11月举行的Android Dev Summit的票是先到先得的方式,所以早早的提交了注册.今天终于有机会当面跟Android系统的设计开发者 ...
- Webstorm 11 注册/破解方法
激活时选择第二个,也就是License server在下面输入框中填http://idea.lanyus.com就行了
- Java IO 之 FileInputStream & FileOutputStream源码分析
Writer :BYSocket(泥沙砖瓦浆木匠) 微 博:BYSocket 豆 瓣:BYSocket FaceBook:BYSocket Twitter ...
- 十家国内知名的EDM服务提供商
国内的EDM服务商多若繁星.下面博主为大家介绍十家国内知名的EDM服务提供商. 一.Webpower 威勃庞尔. 官方网站是:www.webpower.asia.作为全球领先的邮件营销解决方案提供商, ...