PAT甲级——A1117 Eddington Number【25】
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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n;
int main()
{
cin >> n;
vector<int>v(n);
for (int i = ; i < n; ++i)
cin >> v[i];
sort(v.begin(), v.end());
int k = ;
for (k = ; k < n; ++k)
if (v[k] > n - k)
break;
cout << n - k;
return ;
}
PAT甲级——A1117 Eddington Number【25】的更多相关文章
- PAT 甲级 1117 Eddington Number
https://pintia.cn/problem-sets/994805342720868352/problems/994805354762715136 British astronomer Edd ...
- PAT 甲级 1024 Palindromic Number (25 分)(大数加法,考虑这个数一开始是不是回文串)
1024 Palindromic Number (25 分) A number that will be the same when it is written forwards or backw ...
- 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 ...
- A1117. Eddington Number
British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, h ...
- PAT 甲级 1024 Palindromic Number
1024. Palindromic Number (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A ...
- 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甲级】1070 Mooncake (25 分)(贪心水中水)
题意: 输入两个正整数N和M(存疑M是否为整数,N<=1000,M<=500)表示月饼的种数和市场对于月饼的最大需求,接着输入N个正整数表示某种月饼的库存,再输入N个正数表示某种月饼库存全 ...
- 【PAT甲级】1117 Eddington Number (25分)
题意: 输入一个正整数N(<=100000),接着输入N个非负整数.输出最大的整数E使得有至少E个整数大于E. AAAAAccepted code: #define HAVE_STRUCT_TI ...
- PAT甲题题解-1117. Eddington Number(25)-(大么个大水题~)
如题,大水题...贴个代码完事,就这么任性~~ #include <iostream> #include <cstdio> #include <algorithm> ...
随机推荐
- this.$router.push
跳转详情页this.$router.push({ path: `/activityDetails/${id}` })
- Java笔记目录
目录 一.Java语言概述... 1 1.计算机语言发展史... 1 1.1计算机语言的发展... 1 1.2人与计算机做交互... 1 1.3计算机语言... 1 1.4软件... 1 2.Java ...
- thinkphp url重写
可以通过URL重写隐藏应用的入口文件index.php,下面是相关服务器的配置参考:大理石平台精度等级 [ Apache ] httpd.conf配置文件中加载了mod_rewrite.so模块 Al ...
- Delphi exe实例之间传递cmd参数
{Unit1.pas} 通过这个单元的Button,调用另一个实例: procedure TForm1.Button1Click(Sender: TObject); begin ShellExecut ...
- NX二次开发-UFUN多选菜单对话框uc1605
NX11+VS2013 #include <uf.h> #include <uf_ui.h> UF_initialize(); //多选菜单对话框 char sPromptSt ...
- string反向找位置,分割字符串(只取文件夹路径)
1 #include <uf.h> 2 #include <uf_part.h> 3 #include <atlstr.h> 4 #include <iost ...
- 4 丑数 Ⅱ-找出第n个丑数
原题网址:http://www.lintcode.com/zh-cn/problem/ugly-number-ii/ 设计一个算法,找出只含素因子2,3,5 的第 n 小的数. 符合条件的数如:1, ...
- Java-Class-@I:org.springframework.web.bind.annotation.RestController
ylbtech-Java-Class-@I:org.springframework.web.bind.annotation.RestController 1.返回顶部 2.返回顶部 1. pack ...
- Mybatis笔记 - SqlMapConfig
一.基本配置内容 1.基本格式 mybatis的全局配置文件SqlMapConfig.xml,配置内容如下: properties(属性) settings(全局配置参数) typeAliases(类 ...
- HSF简单实现记录( 基于Ali-Tomcat 开发)
文章目录 声明 注意 提示: Ali-Tomcat 概述 安装 Ali-Tomcat 和 Pandora 并配置开发环境 安装 Ali-Tomcat 和 Pandora 配置开发环境 配置 Eclip ...