結果

問題 No.489 株に挑戦
ユーザー hedwig100
提出日時 2020-06-05 21:09:36
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 281 ms / 1,000 ms
コード長 641 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 18,304 KB
最終ジャッジ日時 2024-07-20 00:24:46
合計ジャッジ時間 6,080 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

from collections import deque,defaultdict,Counter
def main():
    N,D,K = map(int,input().split())
    X = [int(input()) for _ in range(N)]

    ans = 0
    L,R = -1,-1
    q = deque([0])
    for i in range(1,N):
        if q[0] < i - D:
            q.popleft()
        if ans < X[i] - X[q[0]]:
            ans = X[i] - X[q[0]]
            L = q[0]
            R = i
        while q and X[q[-1]] > X[i]:
            q.pop()
        q.append(i)
    if L < 0:
        print(0)
    else:
        print(ans * K)
        print(L,R)
if __name__ == '__main__':
    main()
0