結果

問題 No.2210 equence Squence Seuence
ユーザー chankei271828
提出日時 2023-02-10 22:11:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 585 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 82,196 KB
実行使用メモリ 122,496 KB
最終ジャッジ日時 2024-07-07 16:24:59
合計ジャッジ時間 3,891 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N,K=map(int,input().split())
A=list(map(int,input().split()))
d=deque()
ans=[-1]*N
l=0
r=N-1
res=[]
for i in range(N-1):
    if A[i]>A[i+1]:
        res.append(i)
        while res:
            j=res.pop()
            ans[l]=j
            l+=1
    elif A[i]<A[i+1]:
        res.append(i)
        while res:
            j=res.pop()
            ans[r]=j
            r-=1
    else:
        res.append(i)
while res:
    j=res.pop()
    ans[l]=j
    l+=1
ans[l]=N-1
ans_seq=[]
for i in range(N):
    if i!=ans[K-1]:
        ans_seq.append(A[i])
print(*ans_seq)
0