PAT (Basic Level) Practise (中文)1060. 爱丁顿数(25)
来源:互联网 发布:全球煤炭储量知乎 编辑:程序博客网 时间:2024/06/05 10:16
1060. 爱丁顿数(25)
时间限制
250 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue
英国天文学家爱丁顿很喜欢骑车。据说他为了炫耀自己的骑车功力,还定义了一个“爱丁顿数”E,即满足有E天骑车超过E英里的最大整数E。据说爱丁顿自己的E等于87。
现给定某人N天的骑车距离,请你算出对应的爱丁顿数E(<=N)。
输入格式:
输入第一行给出一个正整数N(<=105),即连续骑车的天数;第二行给出N个非负整数,代表每天的骑车距离。
输出格式:
在一行中给出N天的爱丁顿数。
输入样例:106 7 6 9 3 10 8 2 7 8输出样例:
6
#include <cstdio>#include <algorithm>using namespace std;const int maxn=1e5+10;int a[maxn];bool cmp(int a,int b){ return a>b;}int main(){ int n; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&a[i]); sort(a,a+n,cmp); int ans=0; for(int i=0;i<n;i++){ if(a[i]>i+1) ans=i+1; else break; } printf("%d\n",ans); return 0;}
阅读全文
0 0
- PAT (Basic Level) Practise (中文) 1060. 爱丁顿数(25)
- PAT (Basic Level) Practise (中文)1060. 爱丁顿数(25)
- PAT (Basic Level) Practise (中文)1060. 爱丁顿数(25)
- PAT (Basic Level) Practise (中文)
- PAT (Basic Level) Practise (中文)
- PAT (Basic Level) Practise (中文)--1001
- PAT (Basic Level) Practise (中文)
- PAT (Basic Level) Practise (中文)1001
- PAT (Basic Level) Practise (中文)1002
- PAT (Basic Level) Practise (中文) 1007
- PAT (Basic Level) Practise (中文)1015. 德才论 (25)
- PAT (Basic Level) Practise (中文)1020. 月饼 (25)
- PAT (Basic Level) Practise (中文)1030. 完美数列(25)
- PAT (Basic Level) Practise (中文)1020. 月饼 (25)
- PAT (Basic Level) Practise (中文)1020. 月饼 (25)
- PAT (Basic Level) Practise (中文)1030. 完美数列(25)
- PAT (Basic Level) Practise (中文)1050. 螺旋矩阵(25)
- PAT (Basic Level) Practise (中文)1045快速排序(25)
- VB.NET机房收费系统之报表制作(绑定数据源)(二)
- 高效使用Pycharm不完全指南
- OptionSet(静态属性集合)
- 数组指针和指针数组分析
- 关于KinectController跳转场景多个叠加解决方案
- PAT (Basic Level) Practise (中文)1060. 爱丁顿数(25)
- linux环境下安装Redis 启动Redis 在Redis创建KV键值对数据(修)
- SQL(7)
- 天网已成雏形?
- 1385Problem A:Frog
- HDU4046panda (线段树)
- 【数据结构】范浩强Treap(非旋转平衡树)&可持久化Treap总结
- JVM何时会进行全局GC
- 手动编译安装lamp之mysql