Hard deck/리포트
036 : 회의실 배정하기
서버관리자 페페
2022. 7. 29. 19:03
(Briefing) | ||
문제 | 단 하나의 맥락 | 입출력과 되어야 하는 그림 |
1개의 회의실에서 N개의 회의 진행 겹치지 않게 회의를 진행할 때, 최대한 많이 진행하는 회의의 수 |
종료 시간이 빠른 순으로 정렬 | I // 회의의 수 N 회의(1) 시작 시간과 끝나는 시간 ... 회의(N) 시작 시간과 끝나는 시간 |
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// Input Supply Cable
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
// Preprocessing
int[][] A = new int[N][2];
for (int i = 0; i < N; i++) {
A[i][0] = sc.nextInt();
A[i][1] = sc.nextInt();
}
// Operating Sort
Arrays.sort(A, new Comparator<int[]>() {
@Override
public int compare(int[] S, int[] E) {
if (S[1] == E[1]) {
return S[0] - E[0];
}
return S[1] - E[1];
}
});
int count = 0;
int end = -1;
for (int i = 0; i < N; i++) {
if (A[i][0] >= end) {
end = A[i][1];
count++;
}
}
// Output Supply Cable
System.out.println(count);
}
}