結果

問題 No.489 株に挑戦
ユーザー kjnhokjnho
提出日時 2017-02-25 01:13:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,127 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 10,820 KB
実行使用メモリ 14,128 KB
最終ジャッジ日時 2023-09-01 21:52:25
合計ジャッジ時間 12,099 ms
ジャッジサーバーID
(参考情報)
judge16 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 229 ms
11,408 KB
testcase_01 WA -
testcase_02 AC 19 ms
8,536 KB
testcase_03 AC 19 ms
8,388 KB
testcase_04 AC 19 ms
8,456 KB
testcase_05 WA -
testcase_06 AC 19 ms
8,452 KB
testcase_07 AC 19 ms
8,392 KB
testcase_08 AC 19 ms
8,536 KB
testcase_09 AC 19 ms
8,572 KB
testcase_10 AC 19 ms
8,464 KB
testcase_11 AC 19 ms
8,584 KB
testcase_12 AC 20 ms
8,508 KB
testcase_13 WA -
testcase_14 AC 19 ms
8,424 KB
testcase_15 AC 31 ms
8,676 KB
testcase_16 TLE -
testcase_17 AC 47 ms
8,896 KB
testcase_18 AC 236 ms
10,440 KB
testcase_19 AC 296 ms
10,400 KB
testcase_20 TLE -
testcase_21 WA -
testcase_22 AC 40 ms
8,784 KB
testcase_23 AC 152 ms
10,568 KB
testcase_24 TLE -
testcase_25 AC 19 ms
8,528 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 20 ms
8,500 KB
testcase_29 AC 19 ms
8,364 KB
testcase_30 AC 248 ms
13,976 KB
testcase_31 AC 227 ms
14,128 KB
testcase_32 WA -
testcase_33 TLE -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 61 ms
9,004 KB
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

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)]

    h_window = dcopy(values[:D])
    h_window.sort()

    minimum = min(values[:D])
    w_min_index = values[:D].index(minimum)
    min_index = values[:D].index(minimum)
    maximum = max(values[:D+1])
    max_index = values[:D+1].index(maximum)

    MAX = maximum - minimum

    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