結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
86,708 KB
testcase_01 AC 88 ms
86,632 KB
testcase_02 AC 90 ms
86,748 KB
testcase_03 AC 88 ms
86,584 KB
testcase_04 AC 278 ms
88,652 KB
testcase_05 AC 91 ms
86,780 KB
testcase_06 AC 91 ms
86,912 KB
testcase_07 AC 89 ms
86,720 KB
testcase_08 AC 140 ms
87,992 KB
testcase_09 AC 125 ms
88,040 KB
testcase_10 WA -
testcase_11 AC 162 ms
88,276 KB
testcase_12 AC 694 ms
89,020 KB
testcase_13 AC 210 ms
88,800 KB
testcase_14 AC 299 ms
88,644 KB
testcase_15 AC 82 ms
85,192 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+1):           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