結果

問題 No.59 鉄道の旅
コンテスト
ユーザー nebukuro09
提出日時 2016-09-28 16:17:46
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 520 bytes
コンパイル時間 1,579 ms
コンパイル使用メモリ 76,672 KB
実行使用メモリ 338,560 KB
最終ジャッジ日時 2024-12-24 23:09:56
合計ジャッジ時間 24,334 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, raw_input().split())
nimotsu = {}
for _ in xrange(N):
    query = int(raw_input())
    if query > 0:
        if sum(v for k,v in nimotsu.items() if k >= query) < K:
            if query in nimotsu:
                nimotsu[query] += 1
            else:
                nimotsu[query] = 1
    else:
        query *= -1
        if query in nimotsu:
            if nimotsu[query] == 1:
                del nimotsu[query]
            else:
                nimotsu[query] -= 1
    
print sum(nimotsu.values())
0