목록algorithm (61)
현제의 현재이야기

꽃길 문제 푸는데 복습 겸 remind 하려고 풀어봤다. dx, dy = [1,0,-1,0], [0, -1, 0, 1] x, y = 0, 0 n = int(input()) arr = [ tuple(input().split()) for _ in range(n) ] for direction, num in arr: if direction == 'E': x, y = x + (int(num) * dx[0]), y + dy[0] elif direction == 'S': x, y = x + dx[1], y + (int(num) * dy[1]) elif direction == 'W': x, y = x + (int(num) * dx[2]), y + dy[2] else: x, y = x + dx[3], y + (int(n..

17451번: 평행 우주 행성 1에 가기 위해 필요한 것보다 세 배의 속도로, 행성 2의 경우 두 배의 속도로 이동하면, 지구에서는 900의 속도만 쌓으면 된다. www.acmicpc.net import sys from collections import deque input = sys.stdin.readline n = int(input()) speed = list(map(int, input().split())) earth = speed[-1] while len(speed) != 1: speed.pop() if earth > speed[-1]: if earth % speed[-1] != 0: earth = speed[-1] * ((earth // speed[-1]) + 1) else: earth = spe..
백준 11724번을 python으로 풀어보았다. 11724번: 연결 요소의 개수 첫째 줄에 정점의 개수 N과 간선의 개수 M이 주어진다. (1 ≤ N ≤ 1,000, 0 ≤ M ≤ N×(N-1)/2) 둘째 줄부터 M개의 줄에 간선의 양 끝점 u와 v가 주어진다. (1 ≤ u, v ≤ N, u ≠ v) 같은 간선은 한 번만 주 www.acmicpc.net from collections import deque node, line_num = tuple(map(int, input().split())) line = [tuple(map(int, input().split())) for _ in range(line_num)] line = deque(line) def bfs(first, line, line_num, ch..

2512번: 예산 첫째 줄에는 지방의 수를 의미하는 정수 N이 주어진다. N은 3 이상 10,000 이하이다. 다음 줄에는 각 지방의 예산요청을 표현하는 N개의 정수가 빈칸을 사이에 두고 주어진다. 이 값들은 모두 1 이상 www.acmicpc.net n = int(input()) state = list(map(int, input().split())) money = int(input()) left = 0 right = max(state) while right >= left: mid = (left + right) // 2 answer = 0 for budget in state: if budget > mid: answer += mid else: answer += budget if answer > money:..

9205번: 맥주 마시면서 걸어가기 송도에 사는 상근이와 친구들은 송도에서 열리는 펜타포트 락 페스티벌에 가려고 한다. 올해는 맥주를 마시면서 걸어가기로 했다. 출발은 상근이네 집에서 하고, 맥주 한 박스를 들고 출발한다. www.acmicpc.net from collections import deque all = int(input()) answer = [] for _ in range(all): a = int(input()) cvs = deque() # 편의점 h_x, h_y = tuple(map(int, input().split())) for _ in range(a + 1): # 목적지 까지 구해야하기 때문에 k = tuple(map(int, input().split())) cvs.append(k) c..

13414번: 수강신청 입력 데이터는 표준 입력을 사용한다. 입력은 1개의 테스트 데이터로 구성된다. 입력의 첫 번째 줄에는 과목의 수강 가능 인원 K(1 ≤ K ≤ 100,000)와 학생들이 버튼을 클릭한 순서를 기록한 대기목 www.acmicpc.net from collections import deque, OrderedDict k, l = tuple(map(int, input().split())) student = deque() for _ in range(l): a = input() student.appendleft(a) student = list(student) student = list(dict.fromkeys(student)) for _ in range(k): print(student.pop(..