結果

問題 No.59 鉄道の旅
ユーザー nebukuro09nebukuro09
提出日時 2016-09-28 16:17:46
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 520 bytes
コンパイル時間 1,188 ms
コンパイル使用メモリ 77,508 KB
実行使用メモリ 269,444 KB
最終ジャッジ日時 2023-08-26 07:20:32
合計ジャッジ時間 8,506 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
76,360 KB
testcase_01 AC 74 ms
76,128 KB
testcase_02 AC 73 ms
76,320 KB
testcase_03 AC 74 ms
76,448 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

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