8

[백준] 3190 뱀 python

https://www.acmicpc.net/problem/3190 3190번: 뱀 'Dummy' 라는 도스게임이 있다. 이 게임에는 뱀이 나와서 기어다니는데, 사과를 먹으면 뱀 길이가 늘어난다. 뱀이 이리저리 기어다니다가 벽 또는 자기자신의 몸과 부딪히면 게임이 끝난다. 게임 www.acmicpc.net # import sys; input = sys.stdin.readline from collections import deque N = int(input()) K = int(input()) apples = set([tuple(map(int, input().split())) for _ in range(K)]) L = int(input()) change = [input().split() for _ in ran..

STUDY/Algorithm 2021.10.14

[백준] 10845 큐

www.acmicpc.net/problem/10845 10845번: 큐 첫째 줄에 주어지는 명령의 수 N (1 ≤ N ≤ 10,000)이 주어진다. 둘째 줄부터 N개의 줄에는 명령이 하나씩 주어진다. 주어지는 정수는 1보다 크거나 같고, 100,000보다 작거나 같다. 문제에 나와있지 www.acmicpc.net from collections import deque import sys input=sys.stdin.readline n=int(input()) que=deque() cmd_list=[] for i in range(n): cmd_list.append(input().split()) for cmd in cmd_list: if cmd[0] == 'pop': try: print(que.popleft()..

STUDY/Algorithm 2021.02.04

[프로그래머스] LEVEL2 다리를 지나는 트럭,python3, 스택/큐

def solution(bridge_length, weight, truck_weights): answer = 0 ing=[] # 다리를 건너는 트럭 cnt=[] # 트럭당 지난 거리 ed=[] # 다리를 지난 트력 while 1: if (truck_weights == []) and (ing == []): break answer+=1 # count total time for i in range(len(cnt)): # decrease the times of trucks above the bridge cnt[i]-=1 if (cnt!=[])and(cnt[0]==0): ed.append(ing[0]) del cnt[0] del ing[0] if (sum(ing) max_weight: bridge.append(0..

STUDY/Algorithm 2019.10.22