結果

問題 No.489 株に挑戦
コンテスト
ユーザー tnishinaga
提出日時 2017-02-27 04:27:05
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 1,004 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 513 ms
コンパイル使用メモリ 20,952 KB
実行使用メモリ 28,760 KB
最終ジャッジ日時 2026-03-05 00:06:54
合計ジャッジ時間 17,785 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 TLE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import bisect

def problem_input():
    ndk = input().split()
    n = int(ndk[0], 10)
    d = int(ndk[1], 10)
    k = int(ndk[2], 10)
    xlist = [int(input(), 10) for i in range(n)]
    return n, d, k, xlist

def test_input():
    n = 7
    d = 2
    k = 1000
    xlist = [1,3,5,1,4,4,7]
    return n, d, k, xlist

def test_input1():
    n = 5
    d = 4
    k = 100
    xlist = [1,2,1,2,1]
    return n, d, k, xlist

def test_input2():
    n = 5
    d = 1
    k = 100
    xlist = [5,4,3,3,1]
    return n, d, k, xlist

# main
n,d,k,xlist = problem_input()
# n,d,k,xlist = test_input1()

sorted_list = [(xlist[0], 0)]
diff_max = 0
for i in range(1, n):
    while (i - sorted_list[0][1]) > d:
        sorted_list = sorted_list[1:]
    if diff_max < (xlist[i] - sorted_list[0][0]):
        diff_max = xlist[i] - sorted_list[0][0]
        result = (sorted_list[0][1], i)
    bisect.insort(sorted_list, (xlist[i], i))


print(diff_max * k)
if diff_max != 0:
    print("{0} {1}".format(result[0], result[1]))
0