greater<int> ()
문제 이해
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<int> citations) {
int answer = 0;
sort(citations.begin(), citations.end(), greater<int>());
answer = citations[0];
for (int i = 0; i < citations.size(); ++i) {
if (citations[i] < i + 1) {
return i;
}
}
return citations.size();
}
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<int> citations) {
int answer = 0;
sort(citations.begin(), citations.end(), greater<int>());
answer = citations[0];
while(answer){
int h=0;
for(int i=0;i<citations.size();i++){
if(citations[i]>=answer){
h++;
}
if(answer == h) return answer;
}
answer--;
}
return answer;
}