博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PAT甲级——A1117 Eddington Number【25】
阅读量:4541 次
发布时间:2019-06-08

本文共 1249 字,大约阅读时间需要 4 分钟。

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:

106 7 6 9 3 10 8 2 7 8

Sample Output:

6
1 #include 
2 #include
3 #include
4 using namespace std; 5 int n; 6 int main() 7 { 8 cin >> n; 9 vector
v(n);10 for (int i = 0; i < n; ++i)11 cin >> v[i];12 sort(v.begin(), v.end());13 int k = 0;14 for (k = 0; k < n; ++k)15 if (v[k] > n - k)16 break;17 cout << n - k;18 return 0;19 }

 

转载于:https://www.cnblogs.com/zzw1024/p/11461414.html

你可能感兴趣的文章
ASP.NET导出Excel,打开时提示“您尝试打开文件'XXX.xls'的格式与文件扩展名指定文件不一致”...
查看>>
Javaweb之 servlet 开发详解1
查看>>
Restore IP Addresses
查看>>
DWR框架简单应用
查看>>
KMP 学习心得-----转
查看>>
time.strftime:格式化字符串中含中文报错处理
查看>>
模态窗口缓存无法清除怎么办? 在地址上加个随机数吧"&rd=" + new Date().getTime()
查看>>
阿里的weex框架到底是什么
查看>>
Tesis enDYNA
查看>>
FxZ,C#开发职位面试测试题(30分钟内必须完成)
查看>>
[HNOI2007]分裂游戏
查看>>
Pandas基本介绍
查看>>
当拖动滚动条时 出现小图标
查看>>
Django Form 的主要内置字段介绍
查看>>
如何写好一个UITableView
查看>>
XML文件生成C++代码(基于rapidxml)
查看>>
写代码,更需要设计代码
查看>>
iOS:修改项目名
查看>>
SpringCloud-Eureka
查看>>
double在输出为字符串的几种方法效率测试
查看>>