British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an "Eddington number", E -- that is, the maximum integer E such that it is for E days that one rides more than E miles. Eddington's own E was 87.

Now given everyday's distances that one rides for N days, you are supposed to find the corresponding E (≤N).

Input Specification:

Each input file contains one test case. For each case, the first line gives a positive integer N (≤10​5​​), the days of continuous riding. Then N non-negative integers are given in the next line, being the riding distances of everyday.

Output Specification:

For each case, print in a line the Eddington number for these N days.

Sample Input:

10
6 7 6 9 3 10 8 2 7 8

Sample Output:

6

 #include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <set>
using namespace std; const int maxn=;
int dis[maxn]; int main(){
int n;
scanf("%d",&n);
for(int i=;i<=n;i++){
int id;
scanf("%d",&id);
if(id>)id=;
dis[id]++;
}
int cnt=;
int i;
for(i=;i>=;i--){
if(cnt>=i)break;
cnt+=dis[i];
}
printf("%d",i);
}

注意点:其实就是找最大的满足条件的数,条件就是大于指定数的个数是否大于这个数。但是注意从后往前遍历增加时,不能输出大于它的个数,要输出指定数,还有超过100000的数要特殊处理

最新文章

  1. js-JavaScript高级程序设计学习笔记19
  2. Swift - 界面的跳转模式
  3. Pyqt 动态的添加控件
  4. Hadoop生态圈
  5. 2016huasacm暑假集训训练三 F - Jungle Roads
  6. 通过Ajax实现增删改查
  7. Velocity魔法堂系列三:模板与宿主环境通信
  8. [Java Basics] Stack, Heap, Constructor, I/O, Immutable, ClassLoader
  9. css 动画类库Animate.css
  10. TYVJ P1016 装箱问题
  11. mysql-5.6.15_winX64在win764位系统下的安装操作步骤总结
  12. .Net下一个Winform方案可以让MessageBox.Show它显示在父窗口的中间
  13. [译]Java 设计模式之外观
  14. 微信小程序心得
  15. C#文件流的读写
  16. django 生产环境部署建议
  17. ASP.NET Core如何设置请求超时时间
  18. system.Data.Entity.Infrastructure.DbUpdateConcurrencyException: Store update, insert, or delete statement affected an unexpected number of rows (0) 问题
  19. Linux 完整卸载oracle和grid软件
  20. APP主要测试类型及测试点总结

热门文章

  1. CSS属性之position讲解
  2. Linux&#160;学习笔记之超详细基础linux命令&#160;Part&#160;4
  3. Django ModelForm 校验数据格式
  4. springcloud 入门 7 (zuul路由网关)
  5. Spring Boot 技术总结
  6. 将爬取的数据保存到mysql中
  7. [MapReduce_add_1] Windows 下开发 MapReduce 程序部署到集群
  8. pip更新及Requirement already up-to-date解决方法
  9. 【PAT】B1051 复数乘法(15 分)
  10. CSRF 漏洞原理详解及防御方法