题意:

输入一个正整数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. java提取字符串数字,Java获取字符串中的数字

    ================================ ©Copyright 蕃薯耀 2020-01-17 https://www.cnblogs.com/fanshuyao/ 具体的方法如 ...

  2. SQL Server无备份误删数据的恢复

    在正式生产数据库中,因为客户现场管理不规范产生了一条错误数据,由于自身睡眠不佳加上客户方言表达,将编号记错,在没有备份的情况下,直接连远程数据库执行了delete操作. 由于备份设置的是每日0点,当天 ...

  3. dp --A - Super Jumping! Jumping! Jumping!

    A - Super Jumping! Jumping! Jumping! Nowadays, a kind of chess game called “Super Jumping! Jumping! ...

  4. 克里金插值 调用matlab工具箱

    克里金插值 克里金插值是依据协方差函数对随机过程或随机场进行空间建模和插值的回归算法. 克里金插值法的公式为: 式中为待插入的各点的重金属污染值,为已知点的重金属污染值,为每个点的权重值. 用BLUP ...

  5. 复习babel

    对babel进行复习

  6. 获取指定key对应的node节点信息

    需求:之前写的脚本(https://www.cnblogs.com/imdba/p/10197192.html),每个node上都只有一个slot段范围的情况,本次通过测试,实现了,任意段范围的获取方 ...

  7. openlayers画区域

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  8. puthon 字典的 .update() 方法

    1.可以直接更新字典 2.也可以用等号连接,更新一个可迭代对象.

  9. JavaScript - request封装

    request封装--微信小程序使用async,await ES5 参考代码 var request = function(param){ var _this = this; $.ajax({ typ ...

  10. PAT (Basic Level) Practice (中文)1037 在霍格沃茨找零钱 (20 分)

    如果你是哈利·波特迷,你会知道魔法世界有它自己的货币系统 —— 就如海格告诉哈利的:“十七个银西可(Sickle)兑一个加隆(Galleon),二十九个纳特(Knut)兑一个西可,很容易.”现在,给定 ...