結果

問題 No.59 鉄道の旅
ユーザー roiti46roiti46
提出日時 2015-02-24 15:43:31
言語 PyPy2
(7.3.15)
結果
RE  
実行時間 -
コード長 527 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 77,648 KB
実行使用メモリ 88,800 KB
最終ジャッジ日時 2023-08-26 05:36:23
合計ジャッジ時間 4,787 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
86,676 KB
testcase_01 AC 81 ms
86,716 KB
testcase_02 AC 83 ms
86,852 KB
testcase_03 AC 83 ms
86,576 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 124 ms
87,812 KB
testcase_09 AC 113 ms
87,876 KB
testcase_10 RE -
testcase_11 AC 152 ms
87,800 KB
testcase_12 AC 624 ms
88,588 KB
testcase_13 AC 189 ms
88,616 KB
testcase_14 RE -
testcase_15 AC 74 ms
85,136 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)
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