zoukankan      html  css  js  c++  java
  • 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 << 61;
    const double eps=1e-5;
    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=1;i<=n;i++){
                scanf("%d",&a[i]);
            }
            sort(a+1,a+1+n,cmp);
            int ans=-INF;
            for(int i=1;i<=n;i++){
                if(i>a[i]){
                    ans=i-1;break;
                }
            }
            cout<<ans<<endl;
        }
        return 0;
    }
  • 相关阅读:
    Codeforces Round #475 (Div. 1) B. Destruction of a Tree
    HDU
    HihoCoder
    浅谈spfa几个优化
    Codeforces Round #474 E. Alternating Tree
    Wannafly 挑战赛12 D
    2017 Multi-University Training Contest
    2017 Multi-University Training Contest
    斜率优化DP基础XVI Open Cup named after E.V. Pankratiev. GP of Ukraine.K
    斜率优化DP入门_HDU3507_Print Article
  • 原文地址:https://www.cnblogs.com/pk28/p/5305532.html
Copyright © 2011-2022 走看看