比赛题目:
http://acm.hdu.edu.cn/downloads/2018ccpc_hn.pdf
The hh-index of an author is the largest hh where he has at least hh papers with citations not less than hh.
Bobo has published many papers.
Given a0,a1,a2,…,ana0,a1,a2,…,an which means Bobo has published aiai papers with citations exactly ii, find the hh-index of Bobo.
InputThe input consists of several test cases and is terminated by end-of-file.
http://acm.hdu.edu.cn/downloads/2018ccpc_hn.pdf
The hh-index of an author is the largest hh where he has at least hh papers with citations not less than hh.
Bobo has published many papers.
Given a0,a1,a2,…,ana0,a1,a2,…,an which means Bobo has published aiai papers with citations exactly ii, find the hh-index of Bobo.
The first line of each test case contains an integer nn.
The second line contains (n+1)(n+1) integers a0,a1,…,ana0,a1,…,an.
OutputFor each test case, print an integer which denotes the result.
## Constraint
* 1≤n≤2⋅1051≤n≤2⋅105
* 0≤ai≤1090≤ai≤109
* The sum of nn does not exceed 250,000250,000.
Sample Input
1 1 2 2 1 2 3 3 0 0 0 0Sample Output
1 2 0
考点:简单结构体排序+思维题
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node{
int ra;
int cn;
}a[200010];
bool cmp(node a,node b){
return a.cn<b.cn;
}
int main()
{
int n;
while(~scanf("%d",&n)){
long long ans=0;
for(int i=0;i<=n;i++){
scanf("%d",&a[i].ra);
a[i].cn=i;
}
sort(a,a+n+1,cmp);
for(int i=n;i>0;i--){
a[i-1].ra+=a[i].ra;
}
for(int j=n;j>=0;j--){
if(a[j].ra>=a[j].cn) {
ans=j;
break;
}
}
cout<<ans<<endl;
}
}