結果

問題 No.59 鉄道の旅
ユーザー szkhtsszkhts
提出日時 2024-03-17 08:31:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 459 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 11,776 KB
実行使用メモリ 31,776 KB
最終ジャッジ日時 2024-03-17 08:32:08
合計ジャッジ時間 8,411 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 207 ms
25,596 KB
testcase_01 AC 202 ms
25,596 KB
testcase_02 WA -
testcase_03 WA -
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, input().split())
weights = [0] * 1000001
ans = 0

for i in range(n):
    w = int(input())
    tmp = 0
    if w < 0:
        if weights[abs(w)] > 0:
            weights[abs(w)] -= 1
    else:
        if i < k:
           weights[w] += 1
        else:
            tmp = sum(weights[i:])
            if tmp < k:
                weights[w] += 1
        
for i in range(len(weights)):
    ans += weights[i]
    
print(ans)
            
            
0