(Python) 백준 10866 / 덱
·
Coding Test Practice/Python
import sysdeque = []innn = [] # 몇개 들어올지 몰라 리스트로 받음input = sys.stdin.readlinea = int(input())for _ in range(a): innn = input().split() b = innn[0] if len(innn) == 2: c = innn[1] if (b == "push_front"): deque.insert(0, c) elif (b == "push_back"): deque.append(c) elif (b == "pop_front"): if deque: print(deque[0]) del deque[0] else: print(-1) elif (b == "pop_ba..
(Python) 백준 11650 / 좌표 정렬하기
·
Coding Test Practice/Python
import sysinput = sys.stdin.readline # 빠른 입력total_num = int(input())total_list = [[] for _ in range(200001)] # 총 20만개for _ in range(total_num): a, b = map(int, input().split()) a += 100000 # -100000이 0번 인덱스에 오도록 함 total_list[a].append(b) # x위치가 인덱스, y위치가 값 for i in range(0, 200001): if total_list[i]: total_list[i] = sorted(total_list[i]) # 출력을 위한 정렬 for j in total_list[i]: print(..