forDevLife
[이코테]모험가 길드 <그리디> 본문
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);
}
}
'알고리즘' 카테고리의 다른 글
[이코테]만들 수 없는 금액 <그리디> (0) | 2021.05.03 |
---|---|
[이코테]곱하기 혹은 더하기 <그리디> (0) | 2021.05.03 |
[이코테]1이 될 때까지 <그리디> (0) | 2021.05.03 |
[이코테]숫자 카드 게임 <그리디> (0) | 2021.05.01 |
[이코테]큰 수의 법칙 <그리디> (0) | 2021.05.01 |
Comments