From 9e4d9f06d410462b91b9d7b12bc9b668e28df813 Mon Sep 17 00:00:00 2001 From: hangyeol Date: Tue, 18 Mar 2025 20:08:01 +0900 Subject: [PATCH 1/4] =?UTF-8?q?94=EC=B0=A8=201=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\353\260\261\355\225\234\352\262\260.py" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 "live9/test94/\353\254\270\354\240\2341/\353\260\261\355\225\234\352\262\260.py" diff --git "a/live9/test94/\353\254\270\354\240\2341/\353\260\261\355\225\234\352\262\260.py" "b/live9/test94/\353\254\270\354\240\2341/\353\260\261\355\225\234\352\262\260.py" new file mode 100644 index 00000000..c0ad00c8 --- /dev/null +++ "b/live9/test94/\353\254\270\354\240\2341/\353\260\261\355\225\234\352\262\260.py" @@ -0,0 +1,18 @@ +def solution(dirs): + visited = set() + current = (0, 0) + + move = {'U': (0, 1), 'D': (0, -1), 'R': (1, 0), 'L': (-1, 0)} + + for dir in dirs: + x = current[0] + move[dir][0] + y = current[1] + move[dir][1] + + if -5 <= x <= 5 and -5 <= y <= 5: + visited.add(tuple(sorted([current, (x, y)]))) + print(visited) + current = (x, y) + + count = len(visited) + + return count \ No newline at end of file From 3d56dd3ab17c45f513e17369bd31f3fd99ef97ac Mon Sep 17 00:00:00 2001 From: hangyeol Date: Tue, 18 Mar 2025 20:08:07 +0900 Subject: [PATCH 2/4] =?UTF-8?q?94=EC=B0=A8=202=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\353\260\261\355\225\234\352\262\260.py" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "live9/test94/\353\254\270\354\240\2342/\353\260\261\355\225\234\352\262\260.py" diff --git "a/live9/test94/\353\254\270\354\240\2342/\353\260\261\355\225\234\352\262\260.py" "b/live9/test94/\353\254\270\354\240\2342/\353\260\261\355\225\234\352\262\260.py" new file mode 100644 index 00000000..cacbb8e9 --- /dev/null +++ "b/live9/test94/\353\254\270\354\240\2342/\353\260\261\355\225\234\352\262\260.py" @@ -0,0 +1,30 @@ +import heapq + +def solution(book_time): + + book_time.sort() + + start = [] + end = [] + + for time in book_time: + start.append(hourToMinute(time[0])) + end.append(hourToMinute(time[1]) + 10) + + rooms = [] + heapq.heapify(rooms) + + for i in range(len(book_time)): + if rooms and rooms[0] <= start[i]: + heapq.heappop(rooms) + + heapq.heappush(rooms, end[i]) + + return len(rooms) + +def hourToMinute(time): + hour, minute = time.split(":") + + minutes = int(hour) * 60 + int(minute) + + return minutes \ No newline at end of file From 6405779c1a90c57c5b731656254d1b18f1e03738 Mon Sep 17 00:00:00 2001 From: hangyeol Date: Tue, 18 Mar 2025 20:08:16 +0900 Subject: [PATCH 3/4] =?UTF-8?q?94=EC=B0=A8=203=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\353\260\261\355\225\234\352\262\260.py" | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "live9/test94/\353\254\270\354\240\2343/\353\260\261\355\225\234\352\262\260.py" diff --git "a/live9/test94/\353\254\270\354\240\2343/\353\260\261\355\225\234\352\262\260.py" "b/live9/test94/\353\254\270\354\240\2343/\353\260\261\355\225\234\352\262\260.py" new file mode 100644 index 00000000..350b256d --- /dev/null +++ "b/live9/test94/\353\254\270\354\240\2343/\353\260\261\355\225\234\352\262\260.py" @@ -0,0 +1,34 @@ +def solution(stones, k): + start = 0 + end = len(stones) - 1 + max_friends = 0 + + while start <= end: + mid = (start + end) // 2 + + if checkUnderZero(stones, k, mid): + max_friends = mid + start = mid + 1 + else: + end = mid - 1 + + return max_friends + + +# 징검다리 수에서 건너는 사람 수를 빼서 연속된 0이하의 수가 k를 초과하는지 검사 +def checkUnderZero(stones, k, friends): + count = 0 + + for stone in stones: + if stone - friends <= 0: + count += 1 + else: + count = 0 + + if count >= k: + return False + + return True + + +print(checkUnderZero([2, 4, 5, 3, 2, 1, 4, 2, 5, 1], 3, 2)) \ No newline at end of file From a247d535b334a1d137bc86782d7fe61c7ce94e8a Mon Sep 17 00:00:00 2001 From: hangyeol Date: Tue, 18 Mar 2025 22:37:44 +0900 Subject: [PATCH 4/4] =?UTF-8?q?94=EC=B0=A8=203=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\353\260\261\355\225\234\352\262\260.py" | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git "a/live9/test94/\353\254\270\354\240\2343/\353\260\261\355\225\234\352\262\260.py" "b/live9/test94/\353\254\270\354\240\2343/\353\260\261\355\225\234\352\262\260.py" index 350b256d..5e7351d0 100644 --- "a/live9/test94/\353\254\270\354\240\2343/\353\260\261\355\225\234\352\262\260.py" +++ "b/live9/test94/\353\254\270\354\240\2343/\353\260\261\355\225\234\352\262\260.py" @@ -1,6 +1,6 @@ def solution(stones, k): - start = 0 - end = len(stones) - 1 + start = 1 + end = max(stones) max_friends = 0 while start <= end: @@ -20,7 +20,7 @@ def checkUnderZero(stones, k, friends): count = 0 for stone in stones: - if stone - friends <= 0: + if stone - friends < 0: count += 1 else: count = 0 @@ -28,7 +28,4 @@ def checkUnderZero(stones, k, friends): if count >= k: return False - return True - - -print(checkUnderZero([2, 4, 5, 3, 2, 1, 4, 2, 5, 1], 3, 2)) \ No newline at end of file + return True \ No newline at end of file