https://programmers.co.kr/learn/courses/30/lessons/42747#
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<int> ci) {
int answer = 0;
int size = ci.size();
sort(ci.begin(), ci.end());
for(int i=0;i<size;i++){
int h = ci[size - i-1];
if(h <= i + 1){
if(answer <= h)
return h;
else
return answer;
}else if(h >= i+1)
answer = i+1;
}
return answer;
}
include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<int> citations) {
int answer = 0;
std::sort(citations.begin(), citations.end());
for (int i = 0; i < citations.size(); i++) {
if (citations.size() - i <= citations[i]) {
answer = citations.size() - i;
break;
}
}
return answer;
}