PAT_A1117#Eddington Number
Source:
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的更多相关文章
- A1117. Eddington Number
British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, h ...
- 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 ...
- PAT 甲级 1117 Eddington Number
https://pintia.cn/problem-sets/994805342720868352/problems/994805354762715136 British astronomer Edd ...
- 1117 Eddington Number (25 分)
1117 Eddington Number (25 分) British astronomer Eddington liked to ride a bike. It is said that in o ...
- PAT 1117 Eddington Number [难]
1117 Eddington Number (25 分) British astronomer Eddington liked to ride a bike. It is said that in o ...
- 1117. Eddington Number(25)
British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, h ...
- PAT 1117 Eddington Number
British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, h ...
- 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 ...
- PAT1117. Eddington Number
思路:搞懂题意是关键–E满足有共有E天骑车的距离超过E米,求最大的E! 将数组排序,我们假设最大的E是e,e满足条件有e天骑车超过e米,并且e+1不满足有e+1天骑车超过e+1米.那么我们可以逆序统计 ...
随机推荐
- Linux中grep命令,用或的关系查询多个字符串,正则表达式基础说明
请尊重版权:原文:https://blog.csdn.net/lkforce/article/details/52862193 使用 grep 'word1|word2' 文件名 这样的命令是不对的 ...
- 使用 vue.js 的一些操作记录
vue.js不支持ie8以下 1. 在html的属性中赋值: 需要在属性前加上 v-bind
- os.fork()----linux
fork() 函数,它也属于一个内建并 且只在 Linux 系统下存在. 它非常特殊普通的函数调用,一次返 回但是 fork() 调用一次,返回两次.因为操作系统自动把当前进程(称为父)复制了一份(称 ...
- html - body标签中相关标签
body标签中相关标签 今日内容: 字体标签: h1~h6.<font>.<u>.<b>.<strong><em>.<sup> ...
- ArcMap属性表操作接口ITableWindow3
ITableWindow3 tableWindow3 = new TableWindowClass { //Layer = laye ...
- rpcbind服务没法开启问题
昨天下午有部分生产机器无法启动nfs服务:报错很是奇怪.于是一路顺藤摸瓜发现是rpcbind没能正常启动导致的nfs没能起来. 后来总结了两种办法:主要是ipv6的问题所导致的. 措施一: 报错内容 ...
- 从URL输入到页面展现,过程中发生了什么?
从在地址栏中输入了URL,到浏览器展现出页面整个过程中,大概经历了如下过程: 在浏览器地址中输入了URL并回车 域名解析 服务器处理请求 浏览器处理 网页的绘制 一.在浏览器地址中输入URL 首先解释 ...
- myeclipse 报错:Set project compiler compliance settings to '1.5'
myeclipse 报错:Set project compiler compliance settings to '1.5' 解决方法:项目右击-->properties-->java c ...
- 2019-8-31-matlab-画图
title author date CreateTime categories matlab 画图 lindexi 2019-08-31 16:55:59 +0800 2018-2-13 17:23: ...
- JS window对象 userAgent 返回用户代理头的字符串表示(就是包括浏览器版本信息等的字符串) 语法 navigator.userAgent
userAgent 返回用户代理头的字符串表示(就是包括浏览器版本信息等的字符串) 语法 navigator.userAgent 几种浏览的user_agent.,像360的兼容模式用的是IE.极速模 ...