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 <iostream>
#include <algorithm>
using namespace std;
int a[1000000];
int main() {
int n, e = 0;
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
sort(a, a+n, greater<int>());
while(e < n && a[e] > e+1) e++;
printf("%d", e);
return 0;
}

PAT 1117 Eddington Number的更多相关文章

  1. PAT 1117 Eddington Number [难]

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

  2. 1117 Eddington Number (25 分)

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

  3. PAT 甲级 1117 Eddington Number

    https://pintia.cn/problem-sets/994805342720868352/problems/994805354762715136 British astronomer Edd ...

  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. 1117. Eddington Number(25)

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

  6. PAT甲题题解-1117. Eddington Number(25)-(大么个大水题~)

    如题,大水题...贴个代码完事,就这么任性~~ #include <iostream> #include <cstdio> #include <algorithm> ...

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

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

  8. 1117 Eddington Number

    题意:给出了N个数字,确定一个尽可能大的数字E,要求这N个数字中大于E的数字有E个. 思路: 乍一看不知道题目在说啥.静下心来多读几遍题目,在草稿纸上比划比划,发现是个大水题.解释一下样例,原始序列为 ...

  9. PAT_A1117#Eddington Number

    Source: PAT A1117 Eddington Number (25 分) Description: British astronomer Eddington liked to ride a ...

随机推荐

  1. luogu2679 子串

    题目大意 有两个仅包含小写英文字母的字符串 A 和 B.现在要从字符串 A 中取出 k 个互不重叠的非空子串,然后把这 k 个子串按照其在字符串 A 中出现的顺序依次连接起来得到一 个新的字符串,请问 ...

  2. 让ListView回来原来的位置

    让ListView回到原来的位置 当从ListView中的某一个Item跳转到其他的Activity,进行操作之后,ListView可能需要刷新(重新加载数据源),这个时候ListView就会回到原始 ...

  3. ubuntu安装phpstorm

    首先要安装jdk $ java -version java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1 ...

  4. 获取Access数据里所有表的名称和表的字段

    -------------//获取Access数据库表名        public void GetTableName()        {                string connSt ...

  5. MSP430:AD10

    使用的MSP430G2553,为AD10,正常有8路输出,P1.0-P1.7为A0-A7 有七个寄存器, 参考电压可以是VCC或者内部参考电压1.5V或者2.5V 参考时钟可以是内部ADC10OSC ...

  6. Java 中数组的遍历方式

    数组对于每一门编程语言来说都是重要的数据结构之一,当然不同语言对数组的实现及处理也不尽相同. Java 语言中提供的数组是用来存储固定大小的同类型元素. 今天我们就来说一下在java中遍历数组都有哪几 ...

  7. yield from (python生成器)

    #生成器中的yield from是干什么用的(一般多用于线程,协程那)def func(): # for i in 'AB': # yield i yield from 'AB' # 就相当于上面的f ...

  8. Spring Cloud (7) 服务容错保护-Hystrix服务降级

    在微服务架构中,根据业务来拆分成一个个的服务,服务与服务之间可以互相调用,在Spring Cloud可以用RestTemplate+Ribbon和Feign来调用.为了保证其高可用,单个服务通常会集群 ...

  9. Sql Server 优化 SQL 查询:如何写出高性能SQL语句

    1. 首先要搞明白什么叫执行计划? 执行计划是数据库根据SQL语句和相关表的统计信息作出的一个查询方案,这个方案是由查询优化器自动分析产生的,比如一条SQL语句如果用来从一个 10万条记录的表中查1条 ...

  10. CSS——宠物demo

    注意:ul中自带padding值,需要清除. <!DOCTYPE html> <html lang="en"> <head> <meta ...