From bedd1886051dee3dddff15b59009e4a4add9f421 Mon Sep 17 00:00:00 2001 From: vrexpert Date: Fri, 23 Feb 2024 23:59:22 +0900 Subject: [PATCH 1/3] =?UTF-8?q?2024-02-23=20=EB=AC=B8=EC=A0=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SeongHoonC/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/SeongHoonC/README.md b/SeongHoonC/README.md index 567f5f6..9741322 100644 --- a/SeongHoonC/README.md +++ b/SeongHoonC/README.md @@ -11,4 +11,5 @@ | 7차시 | 2024.02.08 | DP | | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/23 | | 8차시 | 2024.02.14 | 정렬 | | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/26 | | 9차시 | 2024.02.21 | bfs | | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/35 | +| 9차시 | 2024.02.21 | bfs | | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/38 | --- From 3a55b44d5d951fea0769f839dc99e278d1ea54ca Mon Sep 17 00:00:00 2001 From: vrexpert Date: Sat, 24 Feb 2024 00:00:04 +0900 Subject: [PATCH 2/3] =?UTF-8?q?2024-02-23=20=EB=AC=B8=EC=A0=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SeongHoonC/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SeongHoonC/README.md b/SeongHoonC/README.md index 9741322..8c01890 100644 --- a/SeongHoonC/README.md +++ b/SeongHoonC/README.md @@ -11,5 +11,5 @@ | 7차시 | 2024.02.08 | DP | | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/23 | | 8차시 | 2024.02.14 | 정렬 | | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/26 | | 9차시 | 2024.02.21 | bfs | | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/35 | -| 9차시 | 2024.02.21 | bfs | | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/38 | +| 9차시 | 2024.02.23 | 그리디 | | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/38 | --- From b182aada32823934dd696b1c5a9a799524907b70 Mon Sep 17 00:00:00 2001 From: vrexpert Date: Sat, 24 Feb 2024 01:21:14 +0900 Subject: [PATCH 3/3] 2024-02-23 solved --- ...0\354\213\244 \353\260\260\354\240\225.kt" | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 "SeongHoonC/greedy/\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.kt" diff --git "a/SeongHoonC/greedy/\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.kt" "b/SeongHoonC/greedy/\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.kt" new file mode 100644 index 0000000..96bdc67 --- /dev/null +++ "b/SeongHoonC/greedy/\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.kt" @@ -0,0 +1,35 @@ +import java.io.BufferedReader +import java.io.InputStreamReader + +fun main() { + val br = BufferedReader(InputStreamReader(System.`in`)) + val n = br.readLine().toInt() + var meets = mutableListOf>() + + for (i in 0 until n) { + val (x, y) = br.readLine().split(" ").map { it.toInt() } + meets.add(x to y) + } + meets.sortWith(compareBy({ it.second }, { it.first })) + + var min = -1 + var count = 0 + for (i in meets.indices) { + val meet = meets[i] + // 회의 시작이 이미 시작한 회의보다 작으면 회의 못함 + if (meet.first < min) { + continue + } + // 회의 끝이 최소값보다 작으면 갱신하고 +1 + if (meet.second > min) { + min = meet.second + count++ + continue + } + // 회의 시작과 끝이 같으면 +1 + if (meet.first == meet.second) { + count++ + } + } + println(count) +}