diff --git a/kokeunho/README.md b/kokeunho/README.md index ebdf838..795fa05 100644 --- a/kokeunho/README.md +++ b/kokeunho/README.md @@ -12,4 +12,5 @@ | 8차시 | 2024.11.17 | 구현 | [인구 이동](https://www.acmicpc.net/problem/16234) | [#28](https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/28) | | 9차시 | 2024.11.26 | 다이나믹 프로그래밍 | [계단 오르기](https://www.acmicpc.net/problem/2579) | [#33](https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/33) | | 10차시 | 2024.11.30 | 자료구조 | [가운데를 말해요](https://www.acmicpc.net/problem/1655) | [#36](https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/36) | +| 11차시 | 2024.12.21 | 그리디 알고리즘 | [회의실 배정](https://www.acmicpc.net/problem/1931) | [#43](https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/43) | --- diff --git "a/kokeunho/\352\267\270\353\246\254\353\224\224 \354\225\214\352\263\240\353\246\254\354\246\230/11-kokeunho.java" "b/kokeunho/\352\267\270\353\246\254\353\224\224 \354\225\214\352\263\240\353\246\254\354\246\230/11-kokeunho.java" new file mode 100644 index 0000000..b61e488 --- /dev/null +++ "b/kokeunho/\352\267\270\353\246\254\353\224\224 \354\225\214\352\263\240\353\246\254\354\246\230/11-kokeunho.java" @@ -0,0 +1,34 @@ +package org.example; + +import java.util.*; + +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[][] meetings = new int[n][2]; + + for (int i = 0; i < n; i++) { + meetings[i][0] = sc.nextInt(); + meetings[i][1] = sc.nextInt(); + } + + Arrays.sort(meetings, (a, b) -> { + if (a[1] == b[1]) { + return Integer.compare(a[0], b[0]); + } + return Integer.compare(a[1], b[1]); + }); + + int count = 0; + int lastEnd = 0; + + for (int i = 0; i < n; i++) { + if (meetings[i][0] >= lastEnd) { + count++; + lastEnd = meetings[i][1]; + } + } + System.out.println(count); + } +} \ No newline at end of file