結果

問題 No.59 鉄道の旅
ユーザー roiti46roiti46
提出日時 2015-02-24 15:44:47
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 529 bytes
コンパイル時間 1,669 ms
コンパイル使用メモリ 77,544 KB
実行使用メモリ 89,052 KB
最終ジャッジ日時 2023-08-26 05:36:29
合計ジャッジ時間 3,665 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
86,504 KB
testcase_01 AC 79 ms
87,136 KB
testcase_02 AC 85 ms
86,572 KB
testcase_03 AC 84 ms
86,492 KB
testcase_04 AC 256 ms
88,584 KB
testcase_05 AC 86 ms
86,872 KB
testcase_06 AC 85 ms
86,648 KB
testcase_07 WA -
testcase_08 AC 125 ms
87,768 KB
testcase_09 AC 113 ms
88,068 KB
testcase_10 WA -
testcase_11 AC 146 ms
87,932 KB
testcase_12 AC 640 ms
88,560 KB
testcase_13 AC 203 ms
88,684 KB
testcase_14 AC 287 ms
89,052 KB
testcase_15 AC 77 ms
85,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
N,K = map(int,raw_input().split())
W = [int(raw_input()) for i in xrange(N)]
mw = 1000001
have = [0]*mw
D = int(math.ceil(mw**0.5))
bucket = [0]*(mw/D+1)
for i in xrange(N):
    p = abs(W[i]/D)
    if W[i] > 0:
        cnt = 0
        for j in xrange(W[i],min(mw,(p+1)*D)): cnt += have[j]
        for j in xrange(p+1,mw/D):     cnt += bucket[j]
        if cnt < K:
            have[W[i]] += 1
            bucket[p] += 1
    elif have[abs(W[i])] > 0:
        have[abs(W[i])] -= 1
        bucket[p] -= 1
print sum(have)
0