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 ...
随机推荐
- 解决 sqlalchemy 报错:(1193, "Unknown system variable 'tx_isolation'")
1出现此报错的原因是使用的mysql8.0 以前用的是:tx_isolation 现在用是: transaction_isolation a.通过升级 sqlalchemy 的方法可以解决此问题, p ...
- form:form的一点体会
留个日程吧,明个写,下班了>>
- linux 抓取访问量排行
需求: 分析图片服务日志,把日志(每个图片访问次数*图片大小的总和)排行,取top10,也就是计算每个url的总访问大小 语句: awk '{a[$1]+=$10;}END{for(i in a){p ...
- Mysql 使用存储过程添加新字段
-- 1, 注意SQL 语句开始处不要空格 -- 2, 在使用 [--] 进行注释时,后面请加空格 USE `test`; -- lastUpdateTime drop procedure if ex ...
- Yii 之控制器创建使用
在根目录下的controllers目录下创建控制器HelloController.php: <?php namespace app\controllers; use yii\web\Contro ...
- 转 vs2010转vs2008 其他的一样
如果你使用VS2010的任何版本写代码,那么在VS2008中就不能打开VS2010的解决方案了,为此,通过以下三步就可以解决了一.对于工程名.sln; 1.用你喜欢的编辑器打开sln文件,比如note ...
- IntelliJ IDEA设置properties文件显示中文
配置这里: 注意:上面是Default Settings,还需要在Settings中设置成上面一样的.
- 解密优秀博士成长史 ——微软亚洲研究院首届博士生学术论坛Panel讨论经验总结
编者按:有人说“一入博门深似海”,读博前应该做好哪些准备?作为一名博士生,应该有怎样的学术或职业规划?导师还是老板?怎样在师生关系上做到双赢?你是导师心目中优秀的博士生吗?相信以上问题在很多同学心中萦 ...
- [转]JVM堆和栈的区别
物理地址 堆的物理地址分配对对象是不连续的.因此性能慢些.在GC的时候也要考虑到不连续的分配,所以有各种算法.比如,标记-消除,复制,标记-压缩,分代(即新生代使用复制算法,老年代使用标记——压缩) ...
- MBProgressHUD 显示方向异常
一直在iphone上使用MBProgressHUD做提示信息视图.一直都没有什么问题,但用在ipad上使用时.却有时会出现显示方向不正常.如ipad屏幕是横的,但当MBProgressHUD出现时却依 ...