1060. 爱丁顿数(25)
来源:互联网 发布:直接进入知乎 编辑:程序博客网 时间:2024/05/16 15:07
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
提交代码
/*先进行一个从大到小的排序,然后满足条件a[i]>(i+1)即可注:数组下标从0开始 就是a[i]>(i+1),从1开始i就不需要加1 */#include<iostream>#include<cstring>#include<algorithm>#include<cstdio>using namespace std;#define N 100000+10int a[N];int n;bool cmp(int x,int y){ return x > y;}int main(){// freopen("input.txt","r",stdin); scanf("%d",&n); for(int i = 0;i < n;i ++){ scanf("%d",&a[i]); } sort(a,a+n,cmp); int i = 0; int cnt = 0; while(a[i]>(i+1)&&cnt<n){ i++; cnt++; } printf("%d\n",cnt); return 0;}
阅读全文
0 0
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25) PAT
- 1060. 爱丁顿数(25)
- 1060. 爱丁顿数(25)
- Sort the Array
- java对链表(环、交叉链表的应用)
- Android 获取listview中的文本 报错:android.widget.LinearLayout cannot be cast to android.widget.TextView
- linq insert The null value cannot be assigned to a member with type System.Int64 which is a non-null
- 出现GC overhead limit exceeded 的解决方案
- 1060. 爱丁顿数(25)
- 【数据库】实验一
- MySQL 存储过程中的游标使用
- 【软考】纠错1-3
- 结构体
- C语言小游戏相关问题,猜测两次后查询成绩排行榜,然后继续猜测并查询成绩排行榜,则排行榜显示为空
- 1061. 判断题(15)
- C
- JAVA课程3 1!到10!