题意:

输入一个正整数N(<=100000),接着输入N个非负整数。输出最大的整数E使得有至少E个整数大于E。

AAAAAccepted code:

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[];
int num[];
map<int,int>mp;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
int cnt=;
for(int i=;i<=n;++i)
cin>>a[i];
sort(a+,a++n);
for(int i=;i<=n;++i){
if(!mp[a[i]])
mp[a[i]]=++cnt;
++num[mp[a[i]]];
}
for(int i=cnt-;i;--i)
num[i]+=num[i+];
int ans=;
for(int i=n;i;--i){
int pos=upper_bound(a+,a++n,i)-a;
if(pos<=n&&num[mp[a[pos]]]>=i){
ans=i;
break;
}
}
cout<<ans;
return ;
}

【PAT甲级】1117 Eddington Number (25分)的更多相关文章

  1. PAT 甲级 1024 Palindromic Number (25 分)(大数加法,考虑这个数一开始是不是回文串)

    1024 Palindromic Number (25 分)   A number that will be the same when it is written forwards or backw ...

  2. PAT 甲级 1117 Eddington Number

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

  3. 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 ...

  4. PAT 甲级 1020 Tree Traversals (25分)(后序中序链表建树,求层序)***重点复习

    1020 Tree Traversals (25分)   Suppose that all the keys in a binary tree are distinct positive intege ...

  5. PAT 甲级 1146 Topological Order (25 分)(拓扑较简单,保存入度数和出度的节点即可)

    1146 Topological Order (25 分)   This is a problem given in the Graduate Entrance Exam in 2018: Which ...

  6. PAT 甲级 1071 Speech Patterns (25 分)(map)

    1071 Speech Patterns (25 分)   People often have a preference among synonyms of the same word. For ex ...

  7. PAT 甲级 1063 Set Similarity (25 分) (新学,set的使用,printf 输出%,要%%)

    1063 Set Similarity (25 分)   Given two sets of integers, the similarity of the sets is defined to be ...

  8. PAT 甲级 1059 Prime Factors (25 分) ((新学)快速质因数分解,注意1=1)

    1059 Prime Factors (25 分)   Given any positive integer N, you are supposed to find all of its prime ...

  9. PAT 甲级 1051 Pop Sequence (25 分)(模拟栈,较简单)

    1051 Pop Sequence (25 分)   Given a stack which can keep M numbers at most. Push N numbers in the ord ...

随机推荐

  1. mybatis_day02

    2.映射器Mapper 相当于dao层,不用写实现类(mybatis底层会采用动态代理模式 会跟我生成实现) 步骤: (1) 创建项目 配置mybatis-config.xml 和昨天一样 (2) 创 ...

  2. Python3标准库:struct二进制数据结构

    1. struct二进制数据结构 struct模块包括一些函数,这些函数可以完成字节串与原生Python数据类型(如数字和字符串)之间的转换. 1.1 函数与Struct类 struct提供了一组处理 ...

  3. 本地服务开启MySQL57提示本地计算机上MySQL服务启动后停止。。。。

    1.首先以管理员身份启动cmd,要不然服务禁止访问. 2.然后在cmd中输入 mysqld --remove mysql或者mysqld --remove mysql57来移除服务. 3.然后进入My ...

  4. MySQL 8 重置 root 密码

    如果 root 密码丢失,如何重置 root 密码? 重置 root 密码:Unix 和 类 Unix 系统: 1.登录 Unix 系统用户(运行MySQL服务器的用户) 2.停止MySQL服务器   ...

  5. WPF 释放嵌入资源

    资源文件名称:默认命名空间.文件名 || 默认命名空间.文件夹名.文件名 /// <summary> /// 提取文件 /// </summary> /// <param ...

  6. JS实现轮播图特效(带二级导航)

    按照国际惯例先放效果图 index.html <!DOCTYPE html> <html lang="en"> <head> <meta ...

  7. Spark学习之路 (二十八)分布式图计算系统[转]

    引言 在了解GraphX之前,需要先了解关于通用的分布式图计算框架的两个常见问题:图存储模式和图计算模式. 图存储模式 巨型图的存储总体上有边分割和点分割两种存储方式.2013年,GraphLab2. ...

  8. 剑指offer-面试题17-打印从1到最大的n位数-数字

    /* 题目: 输入数字n,按顺序打印从1到最大的n位十进制数. 如输入3,打印从1,2,3到999. */ /* 思路: 大数问题转化为字符串或数组. */ #include<iostream& ...

  9. Math Magic ZOJ - 3662

    核心是要想到只枚举最小公倍数的因子 因为转移过程中一单添加了不是最小公倍数的因子,那么结果必然不合法,虽然最终答案是对的,但是这样的答案根本用不上,反而时间复杂度大大增加 #include<cs ...

  10. docker下载镜像太慢的解决方案

    参考链接:https://blog.csdn.net/weixin_43569697/article/details/89279225 docker下载镜像卡死或太慢找了网上很多方法,使用镜像中国也是 ...