当前位置:网站首页>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;
}
边栏推荐
- 接口测试框架实战(二)| 接口请求断言
- 【Harmony OS】【ARK UI】Date 基本操作
- 【Harmony OS】【ARK UI】ETS 上下文基本操作
- 刚上线就狂吸70W粉,新型商业模式“分享购”来了,你知道吗?
- 【Harmony OS】【ArkUI】ets开发 基础页面布局与数据连接
- 【Harmony OS】【FAQ】鸿蒙问题合集1
- Build your own web page on raspberry pie (1)
- Power button 561. An array of split
- 【开发者必看】【push kit】推送服务服务典型问题合集2
- 接口测试框架实战 | 流程封装与基于加密接口的测试用例设计
猜你喜欢

【Harmony OS】【ArkUI】ets开发 图形与动画绘制

GIS数据漫谈(五)— 地理坐标系统

Kotlin-Flow常用封装类:StateFlow的使用

Coordinate knowledge in digital twin campus scenarios

【 Harmony OS 】 【 ano UI 】 lightweight data storage

shell script loop statement

在树莓派上搭建属于自己的网页(1)

Build your own web page on raspberry pie (1)

typescript39-class类的可见修饰符

UV decomposition of biotin - PEG2 - azide | CAS: 1192802-98-4 biotin connectors
随机推荐
typescript43-类型兼容性说明
Secondary development of WinForm controls
【Harmony OS】【ARK UI】Date 基本操作
typescript45-接口之间的兼容性
Kotlin-Flow common encapsulation class: the use of StateFlow
tag单调栈-单调栈预备知识-lt.739. 每日温度
js实现一个 bind 函数
【 Harmony OS 】 【 ano UI 】 lightweight data storage
移动流量的爆发式增长,社交电商如何选择商业模式
【Harmony OS】【ArkUI】ets开发 基础页面布局与数据连接
接口管理工具YApi怎么用?颜值高、易管理、超好用
【Harmony OS】【ARK UI】ets使用startAbility或startAbilityForResult方式调起Ability
Odps temporary query can write SQL, turned out to a named?
IO进程线程->线程->day5
在树莓派上搭建属于自己的网页(2)
设计模式——组合模式、享元模式(Integer缓存)(结构型模式)
Two ways to simulate multi-user login in Jmeter
社交电商:流量红利已尽,裂变营销是最低成本的获客之道
3. 无重复字符的最长子串
Install PostgreSQL on Windows