Brilliant Programmers Show
Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 290 Accepted Submission(s): 94

Problem Description
  Hunan TV holds many talent shows every year, such as Happy Girls and Super Boys which attract the attention of the whole country. This year Hunan University held a new type of talent show called Brilliant Programmers. Millions of programmers had registered online and only top N most brilliant programmers got the opportunity to compete on site. The organizer had hold ten rounds of qualification contest and programmers were ranked by their total scores. The programmers who ranked after N were eliminated.
  The final show continued for a very long time. Initially programmers were ranked by their qualification scores. The rule was special: A challenge may be happen between exactly two adjacent ranked programmers at any time and the lower ranked one tries to solve the other’s problem. If the challenger successfully solves this problem, their ranks exchange. Otherwise their ranks remain unchanged. It is guaranteed that a programmer never involved in two challenges at the same time. The top ranked programmer at last is the champion.
  The show was over but… The hard disk which logs the whole progress was burned out. After data rescue, the number of successful challenges of each programmer was recovered but the final rank was disappeared forever. During the rescue some errors may occur, which lead to some wrong recovered numbers. Is the show possible at all? If it is possible, can you help to find the champion from the very limited information?

Input
  There are multiple test cases.
  Each test case is described in two lines. The first line contains one integer N: the number of programmers. The second line contains a sequence of integers Ai that gives the number of successful challenges of the programmer initially ranked i-th.
1 <= N <= 106, 0 <= Ai <= 109
  The input will finish with the end of file.

Output
  For each case the output contains only one line.
  If it is an impossible show, output “Bad Rescue”. Otherwise if the champion is uniquely determined, output the initial rank of the champion. Output “Unknown” if the champion is not sure.

Sample Input
2
0 1
3
0 1 5
3
0 1 1

Sample Output
2
Bad Rescue
Unknown

Source
2013 ACM-ICPC长沙赛区全国邀请赛——题目重现

Recommend
zhoujiaqi2010 | We have carefully selected several similar problems for you: 6667 6666 6665 6664 6663

写在前面:这道题题目数据有问题,第40组以后的数据没有任何输出。
ios::sync_with_stdio(false);
//输入输出外挂,可以使cin的效率和scanf()一样高。

加上这两个之后,我的代码终于不是超时了,是wa了。55
我的代码

#include <iostream>
using namespace std;
long long int cishu[1000001], cishu2[1000001];
int main()
{ios::sync_with_stdio(false);int ca = 0;int a, n;while (cin >> n){ca++;cishu2[0] = 0;for (int i = 1; i <= n; i++){cin >> cishu[i];cishu2[i] = cishu[i] + cishu2[i - 1] + 1;}if (ca >= 40)continue;a = 0;for (int i = 1; i <= n; i++)if (cishu[i] >= cishu2[i - 1])a = i;long long    int temp1 = 0;long long    int temp2 = 0;for (int i = a + 1; i <= n; i++){if (cishu[i] <= temp1)temp1++;elsetemp2 += cishu[i] - temp1;}int count = cishu2[a - 1] + temp2;if (cishu[a]<count)cout << "Unknown" << endl;else if (cishu[a] == count)cout << a << endl;else if (cishu[a]>count)cout << "Bad Rescu" << endl;}return 0;
}

网上ac代码:

我看不出和我的有任何区别
#include <bits/stdc++.h>using namespace std;int n,ca,flag,t;
long long a[1000005],sum[1000005],t1,t2;int main()
{ios::sync_with_stdio(false);ca=0;while(cin>>n){ca++;sum[0]=0;for(int i=1;i<=n;i++){cin>>a[i];sum[i]=a[i]+sum[i-1]+1;}if(ca>=40)continue;t=0;for(int i=1;i<=n;i++)if(a[i]>=sum[i-1])t=i;t1=t2=0;for(int i=t+1;i<=n;i++){if(a[i]<=t1)t1++;elset2+=a[i]-t1;}if(a[t]>sum[t-1]+t2)cout<<"Bad Rescue"<<endl;else if(a[t]==sum[t-1]+t2)cout<<t<<endl;elsecout<<"Unknown"<<endl;}return 0;
}

Brilliant Programmers Show相关推荐

  1. 自学成为程序员_成为程序员不需要的10件事

    自学成为程序员 Do you have what it takes to become a programmer? Chances are, you will base your answer on ...

  2. 9型人格人口占比数据_数据人格

    9型人格人口占比数据 Big Tech companies make money by mining your data. They refine this data using machine le ...

  3. A Scala Tutorial for Java Programmers

    A Scala Tutorial for Java Programmers English Español 한국어 Deutsch By Michel Schinz and Philipp Halle ...

  4. Animated Eye Candy for Programmers

    作者采用vs2008编译,c#代码 Animated Eye Candy for Programmers By Phillip Piper | 17 Apr 2010 A class library ...

  5. Qt Linguist 开发人员 programmers

    Qt Linguist 开发人员 programmers Qt Linguist 开发人员 programmers 在Qt项目文件中指定翻译源 国际化应用 部署翻译 讲解 Qt Linguist 开发 ...

  6. A good book to learn C#2.0 ----C# 2.0 : Practical Guide for Programmers

    c#2.0,已经出来很久了,相信已经有不少人或多或少了解了它的一些特性了.而这本<C# 2.0 : Practical Guide for Programmers>(作者:Michel d ...

  7. math for programmers(转载)

    英文内容,来自http://steve-yegge.blogspot.com/2006/03/math-for-programmers.html 翻译版见这里 相关内容见c2.com 原文内容如下: ...

  8. A Scala Tutorial for Java programmers之(一)Scala入门:Scala例子,以及如何与Java交互

    本文为初学Scala的Java开发者提供了一个Scala例子(Hello world),并对Scala与Java交互的情况作了一些大致的介绍. AD: 本文源自Michel Schinz和Philip ...

  9. Programmers at Work

    Programmers at Work 出版于1986年,是 Susan Lammers 对19位计算机行业先驱的采访实录,25年过去,计算机这个行业的发展更是让世界有了巨大的变化,物换星移,当年那些 ...

最新文章

  1. ElasticSearch教程——汇总篇
  2. C#面向对象_抽象类
  3. Spring MVC 返回视图时添加的模型数据------POJO
  4. ubuntu~vim操作
  5. mysql数据库truncate 夯住_MySQL如何优雅的删除大表实例详解
  6. Machine Learning(CF-940F)
  7. AndroidStudio_Android使用OkHttp发起Http请求_以及使用时需要注意的点---Android原生开发工作笔记220
  8. 区块链架构与应用(区块链入门篇)
  9. idea 创建项目并同步到git仓库
  10. OFFICE工具条的改进
  11. Windows10重装专业版和mysql缺少dll文件或找不到入口点DLLRegisterServer问题处理
  12. 小米4c一直显示无服务器,小米路由器4C不能上网(连不上网)怎么办?
  13. python如何更改背景颜色_python背景颜色,python改背景色
  14. Git Conventional Commits (Git代码提交说明规范)
  15. Python 核心编程(第二版)——网络编程
  16. WiFi Tethering Usb Tethering
  17. Rocket.chat 安装
  18. 区块链到底能干什么?
  19. Postman(七): postman应用实战
  20. 顶会查找论文的网址和检索方法

热门文章

  1. 使用pytorch从零开始实现YOLO-V3目标检测算法 (二)
  2. 深度学习动手入门:GitHub上四个超棒的TensorFlow开源项目
  3. opencv图像遍历方法速度对比
  4. 九丶青龙运行聚看点教程
  5. 谷歌开发专家带你学AI
  6. java 串口波特率_JAVA串口通信的方法
  7. 联想拯救者15isk装win10系统_笔记本电脑触摸板操作手势合集以拯救者Win10系统为例...
  8. linux kill tl进程,【linux】kill ;杀死某一用户下的所有进程
  9. pytorch 驱动不兼容_解决Pytorch 加载训练好的模型 遇到的error问题
  10. htc one m7刷Linux,HTC one m7官方刷机详细操作教程