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 ...
随机推荐
- Mac OS 中设置VPN(pptp连接方式)
第一步:点击系统设置(如图) 第二步:点击网络,进入网络设置(如图) 第三步:点击+号-创建新服务,创建新的VPN网络连接(如图) 第四步:接口-中选-VPN, VPN类型-中选-PPTP,服务名称- ...
- Mysql 如何设置字段自动获取当前时间
应用场景: 1.在数据表中,要记录每条数据是什么时候创建的,不需要应用程序去特意记录,而由数据数据库获取当前时间自动记录创建时间: 2.在数据库中,要记录每条数据是什么时候修改的,不需要应用程序去特意 ...
- Transaction recovery: lock conflict caught and ignored
Transaction recovery: lock conflict caught and ignored环境:RAC 4节点.oracle 11.2.0.4.redhat 5.9 64bit 问题 ...
- [CoreOS 转载] CoreOS实践指南(四):集群的指挥所Fleet
转载:http://www.csdn.net/article/2015-01-14/2823554/2 摘要:CoreOS是采用了高度精简的系统内核及外围定制的操作系统.ThoughtWorks的软件 ...
- windows 2003服务器网络异常流量的处理办法
最近通过防火墙发现一台服务器的流量占用非常厉害,上传的流量每秒达到100—200Mb/s,几乎占掉了一半的带宽.本来那台服务器上安装了360安全卫士,360安全卫士自身带的网络防火墙只能看进程,而不能 ...
- How to get URL parameters with Javascript?
function getURLParameter(name) { return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '( ...
- 让Extjs EditorGridPanel 编辑时支持方向键
在用 extjs editorgridpanel 进行输入编辑的时候, 默认情况下只支持使用 tab 键可以实现焦点切换, 如果想让editorgridpanel 在编辑时通过方向键来实现焦点跳转切换 ...
- SASS用法指南-转
作者: 阮一峰 日期: 2012年6月19日 原文地址:http://www.ruanyifeng.com/blog/2012/06/sass.html 艹,没想到sass 2012年就有了.现在 ...
- .Net基础
标题 状态 内容 NET应用程序是如何执行的? http://www.cnblogs.com/kingmoon/archive/2012/07/16/2594459.html ...
- dbvis MySQL server version for the right syntax to use near 'OPTION SQL_SELECT_LIMIT=DEFAULT' at line 1
转自:http://www.cnblogs.com/_popc/p/4053593.html 今天使用数据库查询工具DBvis链接mysql数据库时, 发现执行如何sql语句, 都报如下错误: 后来想 ...