Implementation
Time Complexity:
Python
n, l = map(int, input().split())citations = sorted([*map(int, input().split())], reverse=True)length = len(citations)while citations[length - 1] < length and length >= 0:length -= 1cur_h, length = length, len(citations)if cur_h is not n:
C++
#include <bits/stdc++.h>using namespace std;int main() {int n, l;cin >> n >> l;vector<int> citations(n);for (int i = 0; i < n; i++) { cin >> citations[i]; }sort(citations.begin(), citations.end(), greater<int>());
Join the USACO Forum!
Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!