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. PHP生成PDF完美支持中文,解决TCPDF乱码

    PHP生成PDF完美支持中文,解决TCPDF乱码 2011-09-26 09:04 418人阅读 评论(0) 收藏 举报 phpfontsheaderttfxhtml文档 PHP生成PDF完美支持中文 ...

  2. Redis Cluster 设置密码

    两种方式 1.修改配置文件 在每个节点的配置文件里面增加密码选项,一定要加上 masterauth,不然 Redirected 的时候会失败. masterauth redispassword req ...

  3. 安卓真机或者模拟器运行安装应用时提示 Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]解决办法

    有时候为了方便调试APP,会在电脑上开启模拟器来调试我们的代码,有时候会出现 Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract n ...

  4. 力扣算法——139WordBreak【M】

    Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine ...

  5. docker swarm创建swarm集群

    三台linux主机 manager:192.168.100.151 work1:192.168.100.156 work2:192.168.100.157 manager docker swarm i ...

  6. window下eclipse搭建hadoop环境

    1 生成插件jar 1.1 安装java,ant运行环境 1.2 下载hadoop-2.5.0.tar.gz并解压到指定目录 1.3 下载hadoop2x-eclipse-plugin-master. ...

  7. Linux解压rar文件

    Linux解压rar文件(unrar安装和使用,分卷解压) windows平台很多压缩文档为rar文件,那么怎么做到Linux解压rar文件(unrar安装和使用)? 简单,centos5安装unra ...

  8. Ubuntu更换阿里云数据源

    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak sudo vim /etc/apt/sources.list 将里面的内容全部删除修改成 ...

  9. volatile(防止编译器对代码进行优化)

    adj.易变的:无定性的:无常性的:可能急剧波动的 网络挥发性:挥发性的:不稳定的 volatile的变量是说这变量可能会被意想不到地改变,这样,编译器就不会去假设这个变量的值了.

  10. webpack devServer配置项的坑

    本文所用webpack版本为4+,阅读本章的同学请注意区分. webpack默认不需要配置文件 但是你仍可在项目的node_module目录同级目录建立一个webpack.config.js文件进行配 ...