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终端中Ctrl+S卡死
因为初学Linux,在vim中写东西是总是喜欢按Ctrl+s来保存内容导致终端突然卡主,然后上网查资料发现了Ctrl+s 暂停屏幕输出[锁住终端]而对应的按键是Ctrl+q 恢复屏幕输出[解锁终端]
- NetworkComms V2版本与V3版本语法的差异
NetworkComms网络通信框架序言 NetworkComms通信框架中V3版本是一次重要的升级,底层做了诸多改变,但语法上与V2版本相比,差不并不大. 监听端口: V3中 IPEndPoint ...
- linux(Ubuntu) 搭建LAMP环境
1.更新源 sudo apt- get update 2.安装常用软件 SSH.Vim.Git.Tree ①SSH sudo apt-get install openssh-server 管理命令:s ...
- Python之实现一个优先级队列
问题 怎样实现一个按优先级排序的队列? 并且在这个队列上面每次 pop 操作总是返回优先级最高的那个元素 解决方案 下面的类利用 heapq 模块实现了一个简单的优先级队列: import heapq ...
- android中的ContentProvider实现数据共享
为了在应用程序之间交换数据,android中提供了ContentProvider,ContentProvider是不同应用程序之间进行数据交换的标准API.当一个应用程序需要把自己的数据暴露给其他程序 ...
- Redis事务 和 pipleline
1.reidis事务 Redis 事务可以一次执行多个命令, 并且带有以下三个重要的保证: 批量操作在发送 EXEC 命令前被放入队列缓存. 收到 EXEC 命令后进入事务执行,事务中任意命令执行失败 ...
- InnoDB global status
常见参数 Innodb_buffer_pool_pages_free 发现 Innodb_buffer_pool_pages_free 为0 ,则说明buffer_pool 已经被用光,需要增大 in ...
- [转载]Ubuntu Server下配置UTF-8中文环境
转载自:http://www.gaojinbo.com/ubuntu-server%E4%B8%8B%E9%85%8D%E7%BD%AEutf-8%E4%B8%AD%E6%96%87%E7%8E%AF ...
- AE开发中实现Control中的各种图形工具的方法(转)
Controls中的工具基本可以分为两类: 第一类:点击工具图标或按钮后,当前axMapControl的工具即为所点击的工具命令. 前面有Controls 后面有tool的工具都可以用同一类的代码实现 ...
- JavaWeb开发之一《Tomcat服务器的部署、安装及应用》
搬以前写的博客[2014-12-10 21:43] 这几天做了一个Java的程序,然后先把他搭载到Web上,于是学习了基于Tomcat服务器的web开发,这里回顾一下Tomcat服务器的搭建过程. 1 ...