結果

問題 No.2774 Wake up Record 2
ユーザー Theta
提出日時 2024-07-10 15:03:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 538 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 96,060 KB
最終ジャッジ日時 2024-07-10 15:03:18
合計ジャッジ時間 5,467 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import pairwise


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    sorted_A = sorted(A)
    threshold = sorted_A[K - 1]

    is_sleep = ""
    for elm in A:
        if elm <= threshold:
            is_sleep += "x"
        else:
            is_sleep += "o"
    ans = []
    for idx, (prev, next_) in enumerate(pairwise(is_sleep), 2):
        if prev == "x" and next_ == "o":
            ans.append(idx)
    print(len(ans))
    print(*ans)


if __name__ == "__main__":
    main()
0