結果

問題 No.2774 Wake up Record 2
ユーザー manoto43manoto43
提出日時 2024-06-07 21:58:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 574 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 82,316 KB
実行使用メモリ 116,616 KB
最終ジャッジ日時 2024-06-07 21:58:51
合計ジャッジ時間 4,567 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,584 KB
testcase_01 AC 37 ms
51,840 KB
testcase_02 AC 34 ms
52,224 KB
testcase_03 AC 35 ms
52,224 KB
testcase_04 AC 38 ms
51,584 KB
testcase_05 AC 35 ms
51,968 KB
testcase_06 AC 35 ms
52,096 KB
testcase_07 AC 39 ms
51,712 KB
testcase_08 AC 35 ms
51,584 KB
testcase_09 AC 49 ms
69,248 KB
testcase_10 AC 37 ms
52,736 KB
testcase_11 AC 108 ms
78,720 KB
testcase_12 AC 73 ms
76,800 KB
testcase_13 AC 276 ms
85,248 KB
testcase_14 AC 543 ms
90,880 KB
testcase_15 AC 530 ms
91,136 KB
testcase_16 AC 516 ms
91,324 KB
testcase_17 AC 574 ms
116,616 KB
testcase_18 AC 514 ms
90,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def RLE(A):
    tmp = [[A[0],0]]
    now = 0
    for i in range(len(A)):
        if tmp[now][0] == A[i]:
            tmp[now][1] += 1
        else:
            tmp.append([A[i],1])
            now += 1
    return tmp

def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    
    g = sorted(A)[K-1]
    S  = ""

    for a in A:
        if a > g:
            S += "o"
        else:
            S += "x"


    r = RLE(S)
    ans = []
    cnt = 0

    for s,c in r:
        if s == "o":
            ans.append(cnt+1) 
        cnt += c

    print(len(ans))
    print(*ans)


if __name__ == "__main__":
    main()

0