Submission
Status:
[PPPPPPPPPPPP]
Score: 100
User: muekwakungaroo
Problemset: 01.H-index
Language: cpp
Time: 0.432 second
Submitted On: 2025-03-31 13:40:42
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int ar[n];
for(int i=0;i<n;i++){
cin>>ar[i];
}
sort(ar,ar+n);
int l=0,r=1e9+1;
while(l<r){
int mid=(l+r)/2;
if(n-(lower_bound(ar,ar+n,mid)-ar)>=mid){
l=mid+1;
}else{
r=mid;
}
}
cout<<l-1;
return 0;
}
/*
5
1 100 3 2 1
12
2 5 3 8 3 5 8 7 6 0 4 3
20
3 5 2 7 10 9 10 7 9 10 7 5 4 0 4 12 300 7 12 5
*/