Source:

PAT A1117 Eddington Number (25 分)

Description:

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 (≤).

Input Specification:

Each input file contains one test case. For each case, the first line gives a positive integer N (≤), 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

Keys:

  • 模拟题

Code:

 /*
Data: 2019-07-19 18:27:10
Problem: PAT_A1117#Eddington Number
AC: 13:54 题目大意:
E数定义:E天之中,骑行米数超过E的最大天数 基本思路:
从大到小排序,找到最大的i,使A[i]>i
*/ #include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
const int M=1e5+;
int e[M]; int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("Test.txt", "r", stdin);
#endif int n,pos;
scanf("%d", &n);
for(int i=; i<=n; i++)
scanf("%d", &e[i]);
sort(e+,e+n+,greater<int>());
for(pos=; pos<=n; pos++)
if(e[pos] <= pos)
break;
if(pos==n && e[n]>n)
printf("%d", pos);
else
printf("%d", pos-); return ;
}

PAT_A1117#Eddington Number的更多相关文章

  1. A1117. Eddington Number

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

  2. 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 ...

  3. PAT 甲级 1117 Eddington Number

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

  4. 1117 Eddington Number (25 分)

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

  5. PAT 1117 Eddington Number [难]

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

  6. 1117. Eddington Number(25)

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

  7. PAT 1117 Eddington Number

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

  8. 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 ...

  9. PAT1117. Eddington Number

    思路:搞懂题意是关键–E满足有共有E天骑车的距离超过E米,求最大的E! 将数组排序,我们假设最大的E是e,e满足条件有e天骑车超过e米,并且e+1不满足有e+1天骑车超过e+1米.那么我们可以逆序统计 ...

随机推荐

  1. 如何理解 HTML 语义化?

    先看下面两段代码 <div>标题</div> <div> <div>一段文字</div> <div> <div>列表 ...

  2. 25. SPI

  3. git和svn的比较

    当前的市场上主流的两种项目开发版本控制软件就是Git和SVN,那么这二者到底有什么区别呢? 在我们公司,其实两个都用,跟对个人体验,我觉得两者差不多,都是进行代码的版本管理. 我觉得1.由于我是实习生 ...

  4. jumpserver注意事项以及报错处理

    需要注意下面亮点 在使用jumpserver过程中,有一步是系统用户推送,要推送成功,client(后端服务器)要满足以下条件: 后端服务器需要有python.sudo环境才能使用推送用户,批量命令等 ...

  5. Java中File类创建文件

    只需要调用该类的一个方法createNewFile(),但是在实际操作中需要注意一些事项,如判断文件是否存在,以及如何向新建文件中写入数据等. import java.io.*; public cla ...

  6. python图像、视频转字符画

    python图像转字符画需要用到matplotlib.pyplot库,视频转字符画需要用到opencv库,这里的代码基于python 3.5 图像转字符画需要先将图像转为灰度图,转灰度图的公式是 gr ...

  7. PyCharm与git/GitHub取消关联

    如果你从github 上down下的个项目,用pycharm 打开的时候,选择了git管理,导致你只要做了修改,就会有颜失标记,即使没有强迫症,看着也很难受啊 聪敏的我赶快找度娘,总结如下解决方法 在 ...

  8. 9、springcloud整合logback打印sql语句

    Logback是由log4j创始人设计的又一个开源日志组件.logback当前分成三个模块:logback-core.logback- classic和logback-access.logback-c ...

  9. java爬取读者文摘杂志

    java爬虫入门实战练习 此代码仅用于学习研究 此次练习选择了读者文摘杂志网站进行文章爬取 练习中用到的都只是一些简单的方法,不过过程中复习了输入流输出流的使用以及文件的创建写入等知识,对自己还是有所 ...

  10. ICPC2008哈尔滨-A-Array Without Local Maximums

    题目描述 Ivan unexpectedly saw a present from one of his previous birthdays. It is array of n numbers fr ...