当前位置:网站首页>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;
}
边栏推荐
- MCM箱模型建模方法及大气O3来源解析
- Get the Ip tool class
- unity2D横板游戏教程6-敌人AI以及受击动画
- OSI的分层特点、传输过程与三次握手、四次挥手、tcp与udp包头的描述
- Peptides mediated PEG DSPE of phospholipids, targeted functional materials - PEG - RGD/TAT/NGR/APRPG
- 2022/08/02 学习笔记 (day22) 多线程
- 社交电商如何做粉丝运营?云平台怎么选择商业模式?
- GIS数据漫谈(六)— 投影坐标系统
- typescript41-class类的私有修饰符
- High availability, two locations and three centers
猜你喜欢
随机推荐
js garbage collection mechanism
【Harmony OS】【ARK UI】轻量级数据存储
typescript44-对象之间的类兼容器
Common fluorescent dyes to modify a variety of groups and its excitation and emission wavelength data in the data
【Harmony OS】【ARK UI】ets使用startAbility或startAbilityForResult方式调起Ability
Peptides mediated PEG DSPE of phospholipids, targeted functional materials - PEG - RGD/TAT/NGR/APRPG
社交电商如何做粉丝运营?云平台怎么选择商业模式?
业务表解析-余额系统
接口测试如何准备测试数据
unity2D横板游戏教程6-敌人AI以及受击动画
【Harmony OS】【ARK UI】ETS 上下文基本操作
User password verification
Jmeter 模拟多用户登录的两种方法
DDL操作数据库、表、列
修饰生物素DIAZO-生物素-PEG3-DBCO|重氮-生物素-三聚乙二醇-二苯基环辛炔
UV 裂解的生物素-PEG2-叠氮|CAS:1192802-98-4生物素接头
closures in js
超好用的画图工具推荐
刚上线就狂吸70W粉,新型商业模式“分享购”来了,你知道吗?
Windows 安装PostgreSQL









