Submission #377247

#TimeUsernameProblemLanguageResultExecution timeMemory
377247marat0210Hindeks (COCI17_hindeks)C++14
5 / 50
261 ms4332 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >>n; vector <long long> a(n); for (int i = 0; i < n; ++i) { cin >>a[i]; } sort(a.begin(), a.end()); for (int i = n; i >= 0; --i) { int cnt = (upper_bound(a.begin(), a.end(), i) - a.begin()) - (lower_bound(a.begin(), a.end(), i - 1) - a.begin()) + 1; if (cnt >= i) { cout <<i<<endl; return 0; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...