• Home
  • About
    • JOOS photo

      JOOS

      Joos's blog

    • Learn More
    • Email
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

[백준] 11003번 : 최솟값 찾기 with python3

24 Aug 2020

Reading time ~1 minute

문제: https://www.acmicpc.net/problem/11003

풀이

import sys
input = sys.stdin.readline
from collections import deque

n, l = map(int, input().split())
a = [*map(int, input().split())]

dque = deque([])

for i in enumerate(a):
    if dque and dque[0][0] <= i[0]-l: # 인덱스 제거
        dque.popleft()

    while dque and dque[-1][1] > i[1] :  #자기보다 작은 것만 있게 하기
        dque.pop()

    dque.append(i)
    print(dque[0][1], end=' ')



algorithm백준python Share Tweet +1