国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

PAT甲級1117

2019-11-08 19:51:02
字體:
來源:轉載
供稿:網友

1117. Eddington Number(25)

時間限制250 ms內存限制65536 kB代碼長度限制16000 B判題程序Standard作者CHEN, Yue

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 (<=N).

Input Specification:

Each input file contains one test case. For each case, the first line gives a positive integer N(<=105), 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 8Sample Output:
6
#include <cstdio>#include <algorithm>using namespace std;int a[1000000];bool cmp1(int a, int b) {	return a > b;}int main() {	int n;	scanf("%d", &n);	for (int i = 1; i <= n; i++) {		scanf("%d", &a[i]);	}	sort(a + 1, a + n + 1, cmp1);//從大到小排序	int ans = 0;	int p = 1;	while (ans <= n && a[p] > p) {//若滿足,那么1~p-1對應的數肯定是大于p的,然后如果a[p]>p那么剛好就滿足那個愛丁頓數		ans++;		p++;	}	printf("%d", ans);	return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 海伦市| 扬中市| 房产| 高台县| 临沭县| 太康县| 芷江| 和林格尔县| 孟村| 于都县| 东丽区| 崇左市| 阳春市| 南江县| 读书| 辛集市| 集贤县| 安平县| 阳西县| 综艺| 荣成市| 涞水县| 瑞丽市| 稷山县| 青铜峡市| 荆门市| 呼图壁县| 西安市| 长沙县| 甘南县| 峨边| 舞阳县| 朝阳县| 定兴县| 水城县| 达拉特旗| 平潭县| 夏邑县| 奉化市| 苏尼特右旗| 都江堰市|