题意:给出了N个数字,确定一个尽可能大的数字E,要求这N个数字中大于E的数字有E个。

思路: 乍一看不知道题目在说啥。静下心来多读几遍题目,在草稿纸上比划比划,发现是个大水题。解释一下样例,原始序列为6 7 6 9 3 10 8 2 7 8,将其从大到小排序,则是10 9 8 8 7 7 6 6 3 2,(假设下标从1开始),我们这样来理解,第1天骑行10公里(说明有1天超过1);第2天骑行9公里(说明有2天超过2);第3天骑行8公里(说明有3天超过3)...,第6天骑行7公里(说明有6天超过6);第7天骑行6公里(有7天超过7???错了。。退出。。),因此这种情况答案是6,就是这10天中有6天骑行的距离是大于6的。

另外再举几个例子,比如:1 1 1 1,第1天骑行1公里(有1天超过1?不满足,退出),因此这种情况答案是0;再比如:2 2 2 2,第1天骑行2公里(有1天超过1),第2天骑行2公里(有2天超过2?不满足,退出),答案是1。

代码:

#include <cstdio>
#include <algorithm>
using namespace std;
;
int dis[maxn];
bool cmp(int a,int b) {return a>b;}

int main()
{
    int n;
    scanf("%d",&n);
    ;i<=n;i++)
        scanf("%d",&dis[i]);
    sort(dis+,dis+n+,cmp);
    ;
    while(dis[i]>i) i++;
    printf();
    ;
}

1117 Eddington Number的更多相关文章

  1. 1117 Eddington Number (25 分)

    1117 Eddington Number (25 分) British astronomer Eddington liked to ride a bike. It is said that in o ...

  2. PAT 1117 Eddington Number [难]

    1117 Eddington Number (25 分) British astronomer Eddington liked to ride a bike. It is said that in o ...

  3. PAT 甲级 1117 Eddington Number

    https://pintia.cn/problem-sets/994805342720868352/problems/994805354762715136 British astronomer Edd ...

  4. 1117. Eddington Number(25)

    British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, h ...

  5. PAT 1117 Eddington Number

    British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, h ...

  6. PAT甲题题解-1117. Eddington Number(25)-(大么个大水题~)

    如题,大水题...贴个代码完事,就这么任性~~ #include <iostream> #include <cstdio> #include <algorithm> ...

  7. 【PAT甲级】1117 Eddington Number (25分)

    题意: 输入一个正整数N(<=100000),接着输入N个非负整数.输出最大的整数E使得有至少E个整数大于E. AAAAAccepted code: #define HAVE_STRUCT_TI ...

  8. A1117. Eddington Number

    British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, h ...

  9. PAT A1117 Eddington Number (25 分)——数学题

    British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, h ...

随机推荐

  1. caffe2 教程入门(python版)

    学习思路 1.先看官方文档,学习如何使用python调用caffe2包,包括 Basics of Caffe2 - Workspaces, Operators, and Nets Toy Regres ...

  2. C#的静态构造函数.cctor

    静态构造函数操作的是类(而非其实例的)成员.静态构造函数(.cctor)的一些特点:1. 声明和定义形式上,只能有static一个修饰符,不能有任何修饰符和返回值(也不能有void).2. 不能被显示 ...

  3. 转:走近NoSQL数据库的四大家族

    在目前的企业IT架构中,系统管理员以及DBA都会考虑使用NoSQL数据库来解决RDBMS所不能解决的问题,特别是互联网行业.传统的关系型数据库主要以表(table)的形式来存储数据,而无法应对非结构化 ...

  4. 配置 Web 组件服务器 IIS 证书

    用 IIS 6 配置 Web 组件证书(对于 Windows Server 2003)     使用 IIS 管理器向 Web 组件服务器分配证书.对合并池配置中的 Standard Edition ...

  5. 广义线性模型(GLM)

    一.广义线性模型概念 在讨论广义线性模型之前,先回顾一下基本线性模型,也就是线性回归. 在线性回归模型中的假设中,有两点需要提出: (1)假设因变量服从高斯分布:$Y={{\theta }^{T}}x ...

  6. New Concept English three (41)

    31w/m   The typing speed need to improved 43errors The quiet life of the country ahs never appealed ...

  7. falsh developer 快捷键

    1.文件夹搜索是Ctrl+I2.注释// Ctrl+Q 3.注释/*...*/ Ctrl+Shift+Q4. 代码提示 Ctrl+Alt+space5. 复制一行 Ctrl+D ctrl+shift+ ...

  8. NODE 性能优化

    五个手段 “如果你的 node 服务器前面没有 nginx, 那么你可能做错了.”—Bryan Hughes Node.js 是使用 最流行的语言— JavaScript 构建服务器端应用的领先工具 ...

  9. Java学习笔记——基础篇

    Tips1:eclipse中会经常用到System.out.println方法,可以先输入syso,然后eclipse就会自动联想出这个语句了!! 学习笔记: *包.权限控制 1.包(package) ...

  10. Spring核心AOP(面向切面编程)总结

    (尊重劳动成果,转载请注明出处:http://blog.csdn.net/qq_25827845/article/details/75208354冷血之心的博客) 1.AOP概念: 面向切面编程,指扩 ...