結果

問題 No.2210 equence Squence Seuence
ユーザー katonyonko
提出日時 2023-02-10 21:57:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 655 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 81,832 KB
実行使用メモリ 106,892 KB
最終ジャッジ日時 2024-07-07 16:11:50
合計ジャッジ時間 4,001 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
import sys
def input():
  return sys.stdin.readline()[:-1]
N,K=map(int,input().split())
A=list(map(int,input().split()))
front=deque()
back=deque()
tmp=1
flg=0
for i in range(N-1):
  if A[i]>A[i+1]:
    for j in range(tmp):
      front.append(i)
    if i==N-2: back.appendleft(N-1)
    tmp=1
    flg=0
  elif A[i]<A[i+1]:
    for j in range(tmp):
      back.appendleft(i)
    if i==N-2: front.append(N-1)
    tmp=1
    flg=1
  else:
    tmp+=1
    if i==N-2:
      for j in range(tmp):
        if flg==0: back.appendleft(N-1)
        else: back.append(N-1)
k=(front+back)[K-1]
ans=[A[i] for i in range(N) if i!=k]
print(*ans)
0