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 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 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..5e7351d0 --- /dev/null +++ "b/live9/test94/\353\254\270\354\240\2343/\353\260\261\355\225\234\352\262\260.py" @@ -0,0 +1,31 @@ +def solution(stones, k): + start = 1 + end = max(stones) + 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 \ No newline at end of file