-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
22sonamu
authored and
22sonamu
committed
Dec 23, 2022
1 parent
d78a02b
commit 1f72864
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from collections import deque | ||
|
||
N, L = map(int, input().split()) | ||
lst = map(int, input().split()) | ||
|
||
q = deque() | ||
|
||
m = 1000000000 | ||
|
||
m2 = 1000000000 | ||
|
||
answerlst = [] | ||
|
||
for item in lst : | ||
q.append(item) | ||
#큐에 L 길이 이상 원소가 들어갈 경우 | ||
if len(q) > L : | ||
if q[0] == m : | ||
m = m2 | ||
q.popleft() | ||
|
||
|
||
if item <= m : | ||
m = item | ||
else : | ||
if item > m and item <= m2 : | ||
m2 = item | ||
|
||
answerlst.append(m) | ||
|
||
|
||
print(answerlst) | ||
|
||
|