結果

問題 No.59 鉄道の旅
ユーザー roiti46roiti46
提出日時 2015-02-24 15:41:00
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 516 bytes
コンパイル時間 388 ms
コンパイル使用メモリ 6,680 KB
実行使用メモリ 19,552 KB
最終ジャッジ日時 2023-08-26 05:36:44
合計ジャッジ時間 14,718 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
13,656 KB
testcase_01 AC 26 ms
13,696 KB
testcase_02 AC 27 ms
13,520 KB
testcase_03 AC 30 ms
13,704 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 899 ms
13,888 KB
testcase_09 AC 370 ms
13,812 KB
testcase_10 RE -
testcase_11 AC 1,822 ms
13,728 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

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],(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