From f969b4491ade67867a36235bc32cf83793357aba Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Fri, 17 Oct 2025 12:33:59 +0900 Subject: [PATCH 1/4] =?UTF-8?q?Solved:=2028278=20=EC=8A=A4=ED=83=9D=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../28278_\354\212\244\355\203\235_2.py" | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 "INSEA-99/week05/28278_\354\212\244\355\203\235_2.py" diff --git "a/INSEA-99/week05/28278_\354\212\244\355\203\235_2.py" "b/INSEA-99/week05/28278_\354\212\244\355\203\235_2.py" new file mode 100644 index 0000000..ace31b6 --- /dev/null +++ "b/INSEA-99/week05/28278_\354\212\244\355\203\235_2.py" @@ -0,0 +1,31 @@ +# pypy3 +# 시간(ms) : 476 +# 공간(KB) : 140540 + +import sys +from collections import deque +input = sys.stdin.readline + +# 명령어 수행 할 함수 정의 +def push_stack(x): stack.append(x) +def pop_stack(): return stack.pop() if stack else -1 +def get_stack_size(): return len(stack) +def is_stack_empty(): return 1 if not stack else 0 +def peek_stack(): return stack[-1] if stack else -1 + +# 명령어와 함수 맵핑 +commands = { + 1: push_stack, + 2: pop_stack, + 3: get_stack_size, + 4: is_stack_empty, + 5: peek_stack +} + +stack = deque() # stack 선언 +for _ in range(int(input().strip())) : + cmd = list(map(int, input().strip().split())) + result = commands[cmd[0]](*cmd[1:]) # 명령어 dict을 이용하여 함수 실행 + if result is not None : print(result) + + From 45ede9708610e9fa921d94cd71782153642c736e Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Fri, 17 Oct 2025 20:02:53 +0900 Subject: [PATCH 2/4] =?UTF-8?q?Solved:=2018258=20=ED=81=90=2022.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "INSEA-99/week05/18258_\355\201\220_2.py" | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 "INSEA-99/week05/18258_\355\201\220_2.py" diff --git "a/INSEA-99/week05/18258_\355\201\220_2.py" "b/INSEA-99/week05/18258_\355\201\220_2.py" new file mode 100644 index 0000000..b59e44e --- /dev/null +++ "b/INSEA-99/week05/18258_\355\201\220_2.py" @@ -0,0 +1,31 @@ +# pypy3 +# 시간(ms) : 932 +# 공간(KB) : 162568 + +import sys +from collections import deque +input = sys.stdin.readline + +# 명령어 수행 할 함수 정의 +def push_queue(x): queue.append(int(x)) +def pop_queue(): return queue.popleft() if queue else -1 +def get_queue_size(): return len(queue) +def is_queue_empty(): return 1 if not queue else 0 +def queue_front(): return queue[0] if queue else -1 +def queue_back(): return queue[-1] if queue else -1 + +# 명령어와 함수 맵핑 +commands = { + 'push': push_queue, + 'pop': pop_queue, + 'size': get_queue_size, + 'empty': is_queue_empty, + 'front': queue_front, + 'back': queue_back, +} + +queue = deque() # queue 선언 +for _ in range(int(input().strip())) : + cmd = list(input().strip().split()) + result = commands[cmd[0]](*cmd[1:]) # 명령어 dict을 이용하여 함수 실행 + if result is not None : print(result) From e18e59341b9a00042742de27c0e67c7f0fd2712f Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Fri, 17 Oct 2025 20:03:09 +0900 Subject: [PATCH 3/4] =?UTF-8?q?Solved:=2010773=20=EC=A0=9C=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week05/10773_\354\240\234\353\241\234.py" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "INSEA-99/week05/10773_\354\240\234\353\241\234.py" diff --git "a/INSEA-99/week05/10773_\354\240\234\353\241\234.py" "b/INSEA-99/week05/10773_\354\240\234\353\241\234.py" new file mode 100644 index 0000000..73d1603 --- /dev/null +++ "b/INSEA-99/week05/10773_\354\240\234\353\241\234.py" @@ -0,0 +1,15 @@ +# pypy3 +# 시간(ms) : 132 +# 공간(KB) : 114336 + +import sys +from collections import deque +input = sys.stdin.readline + + +q = deque() +for _ in range(int(input().strip())) : + k = int(input().strip()) + if k : q.append(k) # 0이 아니면 추가 + else : q.pop() # 0이면 최근 추가건 제거 +print(sum(q)) \ No newline at end of file From 4151765ca0180827a9f3ec8781846a59da2617f0 Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Fri, 17 Oct 2025 20:12:24 +0900 Subject: [PATCH 4/4] =?UTF-8?q?Solved:=202164=20=EC=B9=B4=EB=93=9C2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week05/2164_\354\271\264\353\223\2342.py" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 "INSEA-99/week05/2164_\354\271\264\353\223\2342.py" diff --git "a/INSEA-99/week05/2164_\354\271\264\353\223\2342.py" "b/INSEA-99/week05/2164_\354\271\264\353\223\2342.py" new file mode 100644 index 0000000..3a70e1d --- /dev/null +++ "b/INSEA-99/week05/2164_\354\271\264\353\223\2342.py" @@ -0,0 +1,14 @@ +# pypy3 +# 시간(ms) : 132 +# 공간(KB) : 121240 + +import sys +from collections import deque +input = sys.stdin.readline + +n = int(input().strip()) +q = deque(list(range(1, n+1))) # 1~n 리스트 생성 +while len(q) != 1 : # 1개 남을 때까지 수행 + q.popleft() + q.append(q.popleft()) +print(q[0]) \ No newline at end of file