Google code jam2015 Qualified Round
来源:互联网 发布:抢票软件收费 编辑:程序博客网 时间:2024/06/08 00:37
Problem A. Standing Ovation
It's opening night at the opera, and your friend is the prima donna (the lead female singer). You will not be in the audience, but you want to make sure she receives a standing ovation -- with every audience member standing up and clapping their hands for her.
Initially, the entire audience is seated. Everyone in the audience has a shyness level. An audience member with shyness levelSi will wait until at least Si other audience members have already stood up to clap, and if so, she will immediately stand up and clap. If
You know the shyness level of everyone in the audience, and you are prepared to invite additional friends of the prima donna to be in the audience to ensure that everyone in the crowd stands up and claps in the end. Each of these friends may have any shyness value that you wish, not necessarily the same. What is the minimum number of friends that you need to invite to guarantee a standing ovation?
Input
The first line of the input gives the number of test cases, T.T test cases follow. Each consists of one line with Smax, the maximum shyness level of the shyest person in the audience, followed by a string of
The string will never end in a 0. Note that this implies that there will always be at least one person in the audience.
Output
For each test case, output one line containing "Case #x: y", where x is the test case number (starting from 1) and y is the minimum number of friends you must invite.
Limits
1 ≤ T ≤ 100.
Small dataset
0 ≤ Smax ≤ 6.
Large dataset
0 ≤ Smax ≤ 1000.
Sample
Input
Output
44 111111 095 1100110 1
Case #1: 0Case #2: 1Case #3: 2Case #4: 0
#include <bits/stdc++.h>using namespace std;char a[1005];int main(){ freopen("A-large-practice.in","r",stdin); freopen("out.txt","w",stdout); int T; scanf("%d",&T); for (int _=1;_<=T;_++) { int n; scanf("%d",&n); getchar(); scanf("%s",a); int sum=0,cnt=0; for (int i=0;i<n+1;i++) { if (i<=cnt) cnt+=(a[i]-'0'); else { sum+=(i-cnt); cnt+=((i-cnt)+(a[i]-'0')); } } printf("Case #%d: %d\n",_,sum); } return 0;}
- Google code jam2015 Qualified Round
- 2009 Google Code Jam Qualification Round 题解
- Google Code Jam 2011 Qualification Round ProblemA
- ACM-2011 Google Code jam Round 1
- Google Code Jam 2012 Qualification Round
- Google Code Jam Qualification Round 2012
- Google code jam Round 1B
- Google Code Jam round 1C总结
- Google Code Jam Great China Round A
- Google Code Jam 2016 Round 1A
- Google code jam 2008 Round 1A(c.Numbers)题解
- google codejam 2009 Qualification Round Problem C code
- 2009 Google Code Jam Round 1C 题解
- Reverse-GOOGLE CODE JAM AFICA 2010 Qualification Round
- T9 Spelling-GOOGLE CODE JAM AFICA 2010 Qualification Round
- Store Credit-GOOGLE CODE JAM AFICA 2010 Qualification Round
- ACM-GOOGLE CODE JAM 2011 Qualification Round 2011(总结)
- Google Code Jam 2010 Qualification Round 2012 Problem B && C
- 利用FRDM-K20D50M开发板制作USBDM/Pemicro_OpenSDA仿真调试器
- Android之自定义 ActionBar 上的菜单(Menu)文字颜色
- debain的useradd默认没有主目录及shell
- POJ1837 DP
- HDOJ 2012 素数判定
- Google code jam2015 Qualified Round
- svn 出现cleanup失败的修复
- iOS开发之UIWindow
- c++11 async启动异步任务的使用方法
- LeetCode 之 House Robber
- android开发步步为营之85:RecyclerView简单使用
- Layout Optimization布局优化工具
- 做星星评级的一个demo,转载大神的
- 偶然发现的一个页面加载缓冲特效 sonic