From 2e2212435668dfc89ca506e6991f445671dda253 Mon Sep 17 00:00:00 2001 From: H0ngJu Date: Tue, 31 Dec 2024 15:07:05 +0900 Subject: [PATCH] 202-12-31 --- H0ngJu/README.md | 1 + ...0\354\213\244 \353\260\260\354\240\225.py" | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 "H0ngJu/\352\267\270\353\246\254\353\224\224/\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.py" diff --git a/H0ngJu/README.md b/H0ngJu/README.md index b9d0d9a..75c8f0c 100644 --- a/H0ngJu/README.md +++ b/H0ngJu/README.md @@ -38,3 +38,4 @@ | 34차시 | 2024.11.19 | 누적합 | [개똥벌레](https://www.acmicpc.net/problem/3020) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/256 | | 35차시 | 2024.11.23 | DP | [전깃줄](https://www.acmicpc.net/problem/2565) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/258 | | 36차시 | 2024.12.02 | 수학 | [머리 톡톡](https://www.acmicpc.net/problem/1241) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/260 | +| 36차시 | 2024.12.31 | 그리디 | [회의실 배정](https://www.acmicpc.net/problem/1931) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/261 | diff --git "a/H0ngJu/\352\267\270\353\246\254\353\224\224/\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.py" "b/H0ngJu/\352\267\270\353\246\254\353\224\224/\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.py" new file mode 100644 index 0000000..44c2ce9 --- /dev/null +++ "b/H0ngJu/\352\267\270\353\246\254\353\224\224/\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.py" @@ -0,0 +1,24 @@ +import sys + +def input() : return sys.stdin.readline().rstrip() + +N = int(input()) # 100000 +info = [tuple(map(int, input().split())) for _ in range(N)] + + +info.sort(key=lambda x: (x[1], x[0])) +# 최대한 많이 넣으려면 빨리 끝나는 회의들을 정렬을 해야함 +# ** 끝나는 시간이 같은 경우를 고려해야함 ** + +tmp_a,tmp_b = info[0][0], info[0][1] +answer = 1 + +for i in range(1,N): + a = info[i][0] + b = info[i][1] + + if a >= tmp_b: + tmp_a, tmp_b = a, b + answer += 1 + +print(answer) \ No newline at end of file