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的数要特殊处理

PAT A1117 Eddington Number (25 分)——数学题的更多相关文章

  1. 【PAT甲级】1117 Eddington Number (25分)

    题意: 输入一个正整数N(<=100000),接着输入N个非负整数.输出最大的整数E使得有至少E个整数大于E. AAAAAccepted code: #define HAVE_STRUCT_TI ...

  2. PAT 甲级 1024 Palindromic Number (25 分)(大数加法,考虑这个数一开始是不是回文串)

    1024 Palindromic Number (25 分)   A number that will be the same when it is written forwards or backw ...

  3. PTA PAT排名汇总(25 分)

    PAT排名汇总(25 分) 计算机程序设计能力考试(Programming Ability Test,简称PAT)旨在通过统一组织的在线考试及自动评测方法客观地评判考生的算法设计与程序设计实现能力,科 ...

  4. PAT甲级——A1117 Eddington Number【25】

    British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, h ...

  5. PAT 1117 Eddington Number [难]

    1117 Eddington Number (25 分) British astronomer Eddington liked to ride a bike. It is said that in o ...

  6. PAT 甲级 1078 Hashing (25 分)(简单,平方二次探测)

    1078 Hashing (25 分)   The task of this problem is simple: insert a sequence of distinct positive int ...

  7. PAT 甲级 1070 Mooncake (25 分)(结构体排序,贪心,简单)

    1070 Mooncake (25 分)   Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autum ...

  8. PAT 甲级 1032 Sharing (25 分)(结构体模拟链表,结构体的赋值是深拷贝)

    1032 Sharing (25 分)   To store English words, one method is to use linked lists and store a word let ...

  9. PAT 甲级 1029 Median (25 分)(思维题,找两个队列的中位数,没想到)*

    1029 Median (25 分)   Given an increasing sequence S of N integers, the median is the number at the m ...

随机推荐

  1. (2)Microsoft office Word 2013版本操作入门_快速选中

    1.快速选中一行 .一段文字: 1.1光标在一行内,双击会选中一个词组.快速点击三下会选中一段, 1.2 鼠标移动到行首,单击击会选中一行,双击选中一段. 1.3 选择全部内容 Ctrl+A  , 1 ...

  2. 列表与for循环

    一.list列表 1.概述 变量:使用变量存储数据,但是,有一个缺点:一个变量每次只能存储一个数据 #需求:存储5个人的年龄,求他们的平均年龄 age1 = 29 age2 = 36 age3 = 3 ...

  3. WEB服务器、HTTP服务器、应用服务器、IIS

    转载:https://www.cnblogs.com/brant/p/7209042.html Web服务器: 基本功能就是提供Web信息浏览服务.它只需支持HTTP协议.HTML文档格式及URL.与 ...

  4. Python:dictionary

    # Python3.4 Eclipse+PyDev 打开Eclipse,找到Help菜单栏,进入Install New Software…选项. # 点击work with:输入框的旁边点击Add…, ...

  5. 2018-01-04 浅尝The Little Prover一书, 重逢Chez Scheme

    书开篇之前说, 本书的目标的一个例子: 证明(reverse (reverse x))对于任何列表x, 结果总是x. (安装Chez Scheme的200字请看最后) 书刚开始, 就用到一个schem ...

  6. c3p0死锁

    1.APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! 抛出以下异常信息: com.mchang ...

  7. Kotlin入门(14)继承的那些事儿

    上一篇文章介绍了类对成员的声明方式与使用过程,从而初步了解了类的成员及其运用.不过早在<Kotlin入门(12)类的概貌与构造>中,提到MainActivity继承自AppCompatAc ...

  8. (网页)Angular.js 中 copy 赋值与 = 赋值 区别

    转自st.gg Angular.js 中 copy 赋值与 = 赋值 区别 为什么用 $scope.user = $scope.master; $scope.master 会跟着 $scope.use ...

  9. Cookie的HttpOnly、secure、domain属性

    Cookie主要属性 Cookie主要属性: path domain max-age expires:是expires的补充,现阶段有兼容性问题:IE低版本不支持,所以一般不单独使用 secure h ...

  10. javascript避免dom事件重复触发

    /** * 为指定控件添加限制性事件, 该事件在触发之后, 会被移除, 并在指定的时间间隔后, 重新绑定, 适用于避免控件事件被误操作重复触发的场景 * @param {String} domID 要 ...