NEU 1683: H-Index
题目描述
Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.
According to the definition of h-index on Wikipedia: "A scientist has index h if h of his/her N papers have at least h citations each, and the other N − h papers have no more than h citations each."
For example, given citations = [3, 0, 6, 1, 5], which means the researcher has 5 papers in total and each of them had received 3, 0, 6, 1, 5 citations respectively. Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, his h-index is 3.
Note: If there are several possible values for h, the maximum one is taken as the h-index.
输入
First line is a non-negative integer T(0 < T <= 10) which indicates there are T testcases.
Then there is a non-negative integer n(0 < n <= 10000) which indicates the length of the citations.
After that follows n non-negative integers arr[i] (0 <= arr[i] <= 3 * n)
输出
Output the h-index
样例输入
1
5
3 0 6 1 5
样例输出
3 一名科研人员的h指数是指他至多有h篇论文分别被引用了至少h次。
样例 输入 n篇论文被引用的次数。输出这个研究人员的h指数。
/* ***********************************************
Author :guanjun
Created Time :2016/3/5 13:17:38
File Name :neu1683.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << ;
const double eps=1e-;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
int x,y;
};
struct cmp{
bool operator()(Node a,Node b){
if(a.x==b.x) return a.y> b.y;
return a.x>b.x;
}
}; bool cmp(int a,int b){
return a>b;
}
int a[maxn];
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int t,n;
cin>>t;
while(t--){
scanf("%d",&n);
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
}
sort(a+,a++n,cmp);
int ans=-INF;
for(int i=;i<=n;i++){
if(i>a[i]){
ans=i-;break;
}
}
cout<<ans<<endl;
}
return ;
}
NEU 1683: H-Index的更多相关文章
- HDU-6278-Jsut$h$-index(主席树)
		
链接: https://vjudge.net/problem/HDU-6278 题意: The h-index of an author is the largest h where he has a ...
 - jQuery—一些常见方法(1)【filter(),not(),has(),next(),prev(),find(),eq(),index(),attr(),】
		
1.filter()和not()方法 filter()和not()是一对反方法,filter()是过滤. filter()方法是针对元素自身.(跟has()方法有区别) <script type ...
 - FFmpeg的H.264解码器源代码简单分析:熵解码(Entropy Decoding)部分
		
===================================================== H.264源代码分析文章列表: [编码 - x264] x264源代码简单分析:概述 x26 ...
 - [LeetCode] 274. H-Index H指数
		
Given an array of citations (each citation is a non-negative integer) of a researcher, write a funct ...
 - 【机器学习Machine Learning】资料大全
		
昨天总结了深度学习的资料,今天把机器学习的资料也总结一下(友情提示:有些网站需要"科学上网"^_^) 推荐几本好书: 1.Pattern Recognition and Machi ...
 - jquery基本操作笔记
		
来源于:http://www.cnblogs.com/webcome/p/5484005.html jq和js 可以共存,不能混用: 1 2 3 4 5 6 $('.box').css('backgr ...
 - layer——源码学习
		
一.根据源码的学习 发现创建弹窗:使用了一些div来组成 zindex 和 index 是自动生成. zindex 表示生成的层次关系 index 用来表示各个层的id 默认class名 h = [& ...
 - 多功能弹窗控件layer
		
开发网站的时候,如何合理运用好各种插件对开发的帮助是很大的. 免去了我们调试各种交互效果, 比如常用的弹窗.气泡.提示.加载.焦点.标签.导航.折叠等等 这里会推荐几个常用的js插件,丰富多样简单易移 ...
 - 面试题:给定数组a,找到最大的j-i, 使a[j]>a[i]
		
第一种方法: 用两重循环对每对点都试一下,然后取最大值即可,时间复杂度为O(n2) #include <iostream> #include <algorithm> using ...
 
随机推荐
- spring之注入类型
			
spring有三种注入类型: set注入: 构造注入: 接口注入: 一.set注入(引用spring官方文档中的例子)(用的最多) 1.首先在代码中我们需要编写成员变量的set方法,如下所示,一般情况 ...
 - P1373 小a和uim之大逃离 (动态规划)
			
题目背景 小a和uim来到雨林中探险.突然一阵北风吹来,一片乌云从北部天边急涌过来,还伴着一道道闪电,一阵阵雷声.刹那间,狂风大作,乌云布满了天空,紧接着豆大的雨点从天空中打落下来,只见前方出现了一个 ...
 - kali 1.1.0  boot failed
			
从几个月前的14.10 daily 版本就有U盘刻录无法启动的现象,相关bug可参见: https://bugs.launchpad.net/ubunt ... reator/+bug ...
 - ajax同步导致ajax上面的代码不执行?
			
js代码:环境:IE11要求:点击一个按钮后,页面xxx的地方立即显示"开始处理...",直到ajax处理结束后,xxx内容才更新为新的处理结果:点击事件执行代码如下:xxx.in ...
 - bzoj1734  [Usaco2005 feb]Aggressive cows 愤怒的牛 二分答案
			
[Usaco2005 feb]Aggressive cows 愤怒的牛 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 407 Solved: 325[S ...
 - 设置java、maven环境变量(怕麻烦以后直接来这里复制)
			
这种方法更为安全,它可以把使用这些环境变量的权限控制到用户级别,如果你需要给某个用户权限使用这些环境变量,你只需要修改其个人用户主目录下的.bash_profile文件就可以了. ·用文本编辑器打开用 ...
 - jvisualvm远程监控 Visual GC plugin  NOT supported for this JVM
			
1. 找到jdk安装目录. 2. 进入jdk的 bin目录,新建文件jstatd.all.policy. 3.编辑jstatd.all.policy文件,内容如下: 4. 给jstatd.all.po ...
 - Python种使用Excel
			
今天用到Excel的相关操作,看了一些资料,借此为自己保存一些用法. 参考资料: python excel 的相关操作 python操作excel之xlrd python操作Excel读写--使用xl ...
 - Struts2 与SpringMVC之比较
			
1.Struts2是类级别的拦截, 一个类对应一个request上下文,SpringMVC是方法级别的拦截,一个方法对应一个request上下文,而方法同时又跟一个url对应,所以说从架构本身上Spr ...
 - Java常用的集合类(转)
			
继上一篇文章http://www.cnblogs.com/EasonJim/p/6937690.html中介绍的集合类有非常多,但是在实际使用中,最常用的应该是下面这几种: Java的集合框架分为Li ...