题意:

输入一个正整数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. Linux中“没有可用的软件包XX,但是它被其他软件包引用”的解决方法

    踩坑经历 今天刚在虚拟机上安装好了ubuntu系统,在执行sudo apt install net-tools 命令时报错"没有可用的软件包net-tools,但是它被其他软件包引用&quo ...

  2. 【剑指Offer】61、把二叉树打印成多行

    题目描述 从上到下按层打印二叉树,同一层结点从左至右输出.每一层输出一行. 题解一:BFS public static ArrayList<ArrayList<Integer>> ...

  3. ubuntu--- tracker/libdeepsort.so 找不到cv报错

    一.刚开始解决尝试:因为“删掉lib下的libdeepsort.so报错”,原先以为是 libdeepsort.so 需要拷贝到 /lib路径下的问题,可是因为后来的工程有的好使,又的不好使了.''' ...

  4. [CF1311F] Moving Points - 树状数组

    Solution 按 \(x\) 关键字升序排序,依次枚举每个点 考虑对任意 \(x_j < x_i\),那么当 \(v_j \leq v_i\) 时,它们不会相交,且 \(dis\) 就是它们 ...

  5. .NET Core 初次上手Swagger

    安装NuGet 程序包=>Swashbuckle.AspNetCore 在  Startup.ConfigureServices  方法里添加注册生成器 //注册Swagger生成器,定义一个和 ...

  6. Java各种类

    1.Object类 equals方法 2.Date类 构造方法 成员方法 DateFormat类 Calendar类 3.System类 StringBuilder原理 构造方法 toString方法 ...

  7. 3、MapReduce详解与源码分析

    文章目录 1 Split阶段 2 Map阶段 2.1分区 2.2排序 3 Shuffle阶段 4 Reduce阶段 1 Split阶段      首先,接到hdf文件输入,在mapreduce中的ma ...

  8. LAMP环境搭建与配置(3)

    PHP配置 查看PHP配置文件的位置 #  /usr/local/php/bin/php   -i  |grep  -i  "loaded configuration file" ...

  9. 与soul上的一个妹子聊天有感

    写此篇的原因: 妹子说,我考上公务员了~,当时自己自己顿时哽咽了,不知道说什么,习惯性的说了句,恭喜恭喜啊.感受到妹子的欢喜与喜悦,我也没必要打扰她的兴致,她开心就好了嘛. 每个人的成就都是自己奋斗的 ...

  10. 今天才知道a标签的href="#"是回到页面顶部

    如题,真的是,做了一年多的开发,今天才知道a标签的href="#"是回到顶部.以前一直以为这是个多么了不起的功能. 顺便扩展一下滑动隐藏和显示按钮(从别处拷贝来的代码) $( do ...