알고리즘
[이코테]모험가 길드 <그리디>
JH_Lucid
2021. 5. 3. 13:02
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
int[] people = new int[N];
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
for(int i=0; i< N; i++) {
people[i] = Integer.parseInt(st.nextToken());
}
Arrays.sort(people);
int count = 0;
int group_cnt = 0; //그룹 최소 인원
for(int i=0; i<N; i++) {
group_cnt ++;
if(group_cnt == people[i]) {
count++;
group_cnt = 0;
}
}
System.out.println(count);
}
}