From 07e9c2f15da058232a69f533da8c6a53a48a6b5b Mon Sep 17 00:00:00 2001 From: JSPark <48265129+pknujsp@users.noreply.github.com> Date: Tue, 6 Feb 2024 22:32:18 +0900 Subject: [PATCH 1/4] 2024-02-06 --- pknujsp/README.md | 3 +- .../33-\354\262\240\353\241\234.py" | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 "pknujsp/\355\201\220/33-\354\262\240\353\241\234.py" diff --git a/pknujsp/README.md b/pknujsp/README.md index d8568f58..9a9e4162 100644 --- a/pknujsp/README.md +++ b/pknujsp/README.md @@ -33,4 +33,5 @@ | 29차시 | 2024.01.18 | DFS, UNION-FIND | [순열 사이클](https://www.acmicpc.net/problem/10451) | [#112](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/112) | | 30차시 | 2024.01.23 | DP | [ABBC](https://www.acmicpc.net/problem/25381) | [#119](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/119) | | 31차시 | 2024.01.30 | SORT | [멀티버스 Ⅱ](https://www.acmicpc.net/problem/18869) | [#123](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/123) | -| 32차시 | 2024.02.04 | BFS | [숨바꼭질 3](https://www.acmicpc.net/problem/13549) | [#127](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/127) | \ No newline at end of file +| 32차시 | 2024.02.04 | BFS | [숨바꼭질 3](https://www.acmicpc.net/problem/13549) | [#127](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/127) | +| 33차시 | 2024.02.06 | 큐 | [철로](https://www.acmicpc.net/problem/13334) | [#132](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/132) | \ No newline at end of file diff --git "a/pknujsp/\355\201\220/33-\354\262\240\353\241\234.py" "b/pknujsp/\355\201\220/33-\354\262\240\353\241\234.py" new file mode 100644 index 00000000..acf2420a --- /dev/null +++ "b/pknujsp/\355\201\220/33-\354\262\240\353\241\234.py" @@ -0,0 +1,28 @@ +from sys import * +from heapq import * + +points = [] + +for _ in range(int(stdin.readline().strip())): + h, o = map(int, stdin.readline().strip().split()) + points.append([min(h, o), max(h, o)]) + +points.sort(key=lambda x: x[1]) +D = int(stdin.readline().strip()) + +max_users = 0 +start_points_list = [] + +for start, destination in points: + if start + D < destination: + continue + heappush(start_points_list, start) + + while start_points_list: + if start_points_list[0] + D >= destination: + break + heappop(start_points_list) + + max_users = max(max_users, len(start_points_list)) + +print(max_users) From 5b540db17f43a145bf4b84ee670dae4f2e0f1808 Mon Sep 17 00:00:00 2001 From: JSPark <48265129+pknujsp@users.noreply.github.com> Date: Mon, 12 Feb 2024 23:01:20 +0900 Subject: [PATCH 2/4] 2024-02-12 --- ...4 \352\267\270\353\236\230\355\224\204.py" | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 "pknujsp/BFS/33-\354\235\264\353\266\204 \352\267\270\353\236\230\355\224\204.py" diff --git "a/pknujsp/BFS/33-\354\235\264\353\266\204 \352\267\270\353\236\230\355\224\204.py" "b/pknujsp/BFS/33-\354\235\264\353\266\204 \352\267\270\353\236\230\355\224\204.py" new file mode 100644 index 00000000..34b5a842 --- /dev/null +++ "b/pknujsp/BFS/33-\354\235\264\353\266\204 \352\267\270\353\236\230\355\224\204.py" @@ -0,0 +1,43 @@ +from sys import * +from collections import * + + +def bfs(start): + q = deque([start]) + groups[start] = 1 + + while q: + curr = q.popleft() + visited[curr] = True + + for adj in graph[curr]: + if visited[adj]: + continue + + if not groups[adj]: + groups[adj] = -groups[curr] + q.append(adj) + elif groups[adj] == groups[curr]: + return False + return True + + +for _ in range(int(stdin.readline())): + V, E = map(int, stdin.readline().split()) + graph = [[] for i in range(V + 1)] + + for _ in range(E): + a, b = map(int, stdin.readline().split()) + graph[a].append(b) + graph[b].append(a) + + groups = [0] * (V + 1) + visited = [False] * (V + 1) + result = None + + for i in range(1, V + 1): + if groups[i] == 0 and not bfs(i): + result = 'NO' + break + + print('YES' if not result else result) From e861d2b0830dfc3b13490dad118fb5ad3d022dfc Mon Sep 17 00:00:00 2001 From: JSPark <48265129+pknujsp@users.noreply.github.com> Date: Wed, 14 Feb 2024 14:37:02 +0900 Subject: [PATCH 3/4] 2024-02-14 --- pknujsp/README.md | 4 ++- ...40\353\254\274\355\225\240\354\235\270.py" | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 "pknujsp/\352\267\270\353\246\254\353\224\224/35-\354\204\240\353\254\274\355\225\240\354\235\270.py" diff --git a/pknujsp/README.md b/pknujsp/README.md index 9a9e4162..99ad2452 100644 --- a/pknujsp/README.md +++ b/pknujsp/README.md @@ -34,4 +34,6 @@ | 30차시 | 2024.01.23 | DP | [ABBC](https://www.acmicpc.net/problem/25381) | [#119](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/119) | | 31차시 | 2024.01.30 | SORT | [멀티버스 Ⅱ](https://www.acmicpc.net/problem/18869) | [#123](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/123) | | 32차시 | 2024.02.04 | BFS | [숨바꼭질 3](https://www.acmicpc.net/problem/13549) | [#127](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/127) | -| 33차시 | 2024.02.06 | 큐 | [철로](https://www.acmicpc.net/problem/13334) | [#132](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/132) | \ No newline at end of file +| 33차시 | 2024.02.06 | 큐 | [철로](https://www.acmicpc.net/problem/13334) | [#132](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/132) | +| 34차시 | 2024.02.12 | BFS | [이분 그래프](https://www.acmicpc.net/problem/1707) | [#135](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/135) | +| 35차시 | 2024.02.14 | 그리디 | [선물할인](https://www.acmicpc.net/problem/25947) | [#137](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/137) | diff --git "a/pknujsp/\352\267\270\353\246\254\353\224\224/35-\354\204\240\353\254\274\355\225\240\354\235\270.py" "b/pknujsp/\352\267\270\353\246\254\353\224\224/35-\354\204\240\353\254\274\355\225\240\354\235\270.py" new file mode 100644 index 00000000..85520b1e --- /dev/null +++ "b/pknujsp/\352\267\270\353\246\254\353\224\224/35-\354\204\240\353\254\274\355\225\240\354\235\270.py" @@ -0,0 +1,36 @@ +from sys import * + +n, budget, max_sales = map(int, stdin.readline().split()) +gifts = sorted(list(map(int, stdin.readline().split()))) + +min_price_gift = max_price_gift = 0 +prices = 0 +sales = 0 + +for sale_gift in range(max_sales): + prices += gifts[sale_gift] // 2 + max_price_gift += 1 + + if prices > budget: + print(sale_gift) + exit() + +sales = max_price_gift - min_price_gift +while max_price_gift < n: + if sales < max_sales or max_sales == 0: + if max_sales == 0: + prices += gifts[max_price_gift] + else: + prices += gifts[max_price_gift] // 2 + + if prices > budget: + break + + max_price_gift += 1 + sales += 1 + else: + prices += gifts[min_price_gift] // 2 + min_price_gift += 1 + sales -= 1 + +print(max_price_gift) From 7e1d50c5df3f4ae14859114347d9b10cb33917be Mon Sep 17 00:00:00 2001 From: JSPark <48265129+pknujsp@users.noreply.github.com> Date: Sun, 18 Feb 2024 19:36:50 +0900 Subject: [PATCH 4/4] 2024-02-18 --- pknujsp/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pknujsp/README.md b/pknujsp/README.md index 99ad2452..c9fac876 100644 --- a/pknujsp/README.md +++ b/pknujsp/README.md @@ -36,4 +36,4 @@ | 32차시 | 2024.02.04 | BFS | [숨바꼭질 3](https://www.acmicpc.net/problem/13549) | [#127](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/127) | | 33차시 | 2024.02.06 | 큐 | [철로](https://www.acmicpc.net/problem/13334) | [#132](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/132) | | 34차시 | 2024.02.12 | BFS | [이분 그래프](https://www.acmicpc.net/problem/1707) | [#135](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/135) | -| 35차시 | 2024.02.14 | 그리디 | [선물할인](https://www.acmicpc.net/problem/25947) | [#137](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/137) | +| 35차시 | 2024.02.18 | 그리디 | [선물할인](https://www.acmicpc.net/problem/25947) | [#137](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/137) |