国产探花免费观看_亚洲丰满少妇自慰呻吟_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;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 嫩江县| 阿尔山市| 当阳市| 广灵县| 大荔县| 体育| 托克托县| 正宁县| 河东区| 桐柏县| 汤原县| 冀州市| 灵丘县| 金川县| 平远县| 曲阳县| 奉节县| 同江市| 绥宁县| 清原| 丹巴县| 千阳县| 翼城县| 开原市| 镇江市| 瑞金市| 庆元县| 滦南县| 永胜县| 无棣县| 杭州市| 嵩明县| 郓城县| 大理市| 敖汉旗| 山西省| 左权县| 个旧市| 高密市| 绍兴市| 若羌县|