結果

問題 No.489 株に挑戦
ユーザー kjnhokjnho
提出日時 2017-02-25 01:30:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,232 bytes
コンパイル時間 1,203 ms
コンパイル使用メモリ 10,804 KB
実行使用メモリ 14,284 KB
最終ジャッジ日時 2023-09-01 21:53:29
合計ジャッジ時間 13,029 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 227 ms
11,520 KB
testcase_01 AC 387 ms
11,052 KB
testcase_02 AC 19 ms
8,384 KB
testcase_03 AC 19 ms
8,476 KB
testcase_04 AC 18 ms
8,420 KB
testcase_05 AC 19 ms
8,496 KB
testcase_06 AC 19 ms
8,480 KB
testcase_07 AC 19 ms
8,572 KB
testcase_08 AC 19 ms
8,428 KB
testcase_09 AC 18 ms
8,580 KB
testcase_10 AC 19 ms
8,424 KB
testcase_11 AC 19 ms
8,392 KB
testcase_12 AC 19 ms
8,512 KB
testcase_13 AC 19 ms
8,484 KB
testcase_14 AC 19 ms
8,488 KB
testcase_15 AC 31 ms
8,804 KB
testcase_16 TLE -
testcase_17 AC 46 ms
9,084 KB
testcase_18 AC 239 ms
10,476 KB
testcase_19 AC 289 ms
10,164 KB
testcase_20 TLE -
testcase_21 AC 90 ms
9,796 KB
testcase_22 AC 40 ms
8,704 KB
testcase_23 AC 149 ms
10,372 KB
testcase_24 TLE -
testcase_25 AC 19 ms
8,428 KB
testcase_26 AC 886 ms
13,744 KB
testcase_27 WA -
testcase_28 AC 19 ms
8,464 KB
testcase_29 AC 18 ms
8,460 KB
testcase_30 AC 217 ms
14,284 KB
testcase_31 AC 198 ms
13,900 KB
testcase_32 WA -
testcase_33 TLE -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 58 ms
9,092 KB
testcase_37 AC 373 ms
11,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import deepcopy as dcopy
import bisect
def main():
    N,D,K = map(int, input().split())
    values = [int(input()) for i in range(N)]

    minimum = values[0]
    w_min_index = 0
    MAX = 0
    for i in range(1, D+1):
        if values[i] - minimum > MAX:
            min_index = w_min_index
            max_index = i
            MAX = values[i] - minimum
            
        # for next
        if values[i] < minimum:
            w_min_index = i
            minimum = values[i]

    h_window = sorted(values[:D])
    for j in range(D+1, N):
        del h_window[bisect.bisect_left(h_window, values[j-D-1])]

        if len(h_window) == 0:
            w_min_index = j-1
        elif values[j-1] < h_window[0]:
            w_min_index = j-1

        bisect.insort(h_window, values[j-1])
        minimum = h_window[0]
        tmp = values[j] - minimum
        if tmp > MAX:
            MAX = tmp
            max_index = j
            min_index = w_min_index

    # print(MAX, min_index, max_index)

    if MAX <= 0:
        print(0)
    else:
        print(K*MAX)
        print(min_index, max_index)

if __name__ == "__main__":  # {{{
    try:
        import test
        test.test()
    except:
        main()  # }}}

 
0