풀이 소요시간 : 15분
기본 정렬문제다. lower_bound
메소드를 활용하면 쉽게 풀 수 있다.
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int Ans = 0;
int solution(vector<int> citations) {
sort(citations.begin(), citations.end());
while(true)
{
int element =
citations.end() - lower_bound(citations.begin(), citations.end(), Ans);
if(element >= Ans)
{
Ans += 1;
continue;
}
return Ans - 1;
}
}