当前位置:网站首页>1060 爱丁顿数 (25 分)
1060 爱丁顿数 (25 分)
2022-08-03 05:09:00 【破烂摆烂人】
英国天文学家爱丁顿很喜欢骑车。据说他为了炫耀自己的骑车功力,还定义了一个“爱丁顿数” E ,即满足有 E 天骑车超过 E 英里的最大整数 E。据说爱丁顿自己的 E 等于87。
现给定某人 N 天的骑车距离,请你算出对应的爱丁顿数 E(≤N)。
输入格式:
输入第一行给出一个正整数 N (≤10
5
),即连续骑车的天数;第二行给出 N 个非负整数,代表每天的骑车距离。
输出格式:
在一行中给出 N 天的爱丁顿数。
输入样例:
10
6 7 6 9 3 10 8 2 7 8
输出样例:
6
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int cmp(const void *a, const void *b) {
return *(int *)b - *(int *)a;//降序
}
int main(int argc, char *argv[]) {
int n ;
scanf("%d",&n) ;
int a[100000] ;
int i , j ;
int cnt = 0 , tmp;
for( i = 0 ; i < n ; i++ ){
scanf("%d",&a[i]) ;
}
qsort(a,n,sizeof(int),cmp) ;
for( i = 0 ; i < n ; i++ ){
if( i+1 < a[i] ){
cnt++ ;
}
}
printf("%d",cnt) ;
return 0;
}
边栏推荐
猜你喜欢
随机推荐
接口测试框架实战(三)| JSON 请求与响应断言
typescript43-类型兼容性说明
Shell conditional statement judgment
Shell条件语句判断
WebSocket的实际应用
接口和抽象
js implements a bind function
js实现一个 bind 函数
接口和协议
接口测试框架实战 | 流程封装与基于加密接口的测试用例设计
【Harmony OS】【ARK UI】Date 基本操作
How to prepare for the test interface test data
Common fluorescent dyes to modify a variety of groups and its excitation and emission wavelength data in the data
【Harmony OS】【FAQ】Hongmeng Questions Collection 1
MCM箱模型建模方法及大气O3来源解析
rosbag工具plotjuggler无法打开rosbag的问题
Jmeter 模拟多用户登录的两种方法
User password encryption tool
JS底层手写
Modified BiotinDIAZO-Biotin-PEG3-DBCO|diazo-biotin-tripolyethylene glycol-diphenylcyclooctyne