Submission

Status:
[PPPPPPPPPPPP]

Score: 100

User: chawinkn

Problemset: 01.H-index

Language: cpp

Time: 0.360 second

Submitted On: 2025-03-31 02:08:36

#include <bits/stdc++.h>
using namespace std;

#define ll long long

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (auto& i : a) cin >> i;
	sort(a.begin(), a.end());
	ll l=0, r=1e10;
	while (l < r) {
		ll m=(l+r+1)/2;
		ll i=lower_bound(a.begin(), a.end(), m)-a.begin();
		if (n-i >= m) l = m;
		else r = m-1;
	}
	cout << l;
	return 0;
}