# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
856069 | vjudge1 | Hindeks (COCI17_hindeks) | C++17 | 70 ms | 4344 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,O3,unroll-loops")
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpi vector<pii>
#define vvpi vector<vpi>
#define vb vector<bool>
#define vvb vector<vb>
#define endl "\n"
#define sp << " " <<
#define F(i, s, n) for(int i = s; i < n; i++)
#define pb push_back
#define fi first
#define se second
int mod = 998244353;
int inf = LLONG_MAX >> 3;
int mult(int x, int y) {
return (x%mod)*(y%mod)%mod;
}
void solve() {
int n;
cin >> n;
int a[n];
F(i, 0, n) cin >> a[i];
sort(a, a + n);
int l = 0, r = n, ans = 0;
while(l <= r) {
int m = (l + r) >> 1;
int le = n - (lower_bound(a, a+n, m) - a);
//cout << m sp le << endl;
if(le >= m) {
ans = max(m, ans);
l = m + 1;
} else {
r = m - 1;
}
}
cout << ans << endl;
}
void setIO() {
ios::sync_with_stdio(0); cin.tie(0);
#ifdef Local
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
}
signed main() {
setIO();
int t = 1;
//cin >> t;
while(t--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |