結果

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

ソースコード

diff #

from collections import *
import sys

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())

def main():
    ii=deque()
    xx=deque()
    n,d,k=MI()
    aa=[II() for _ in range(n)]
    mx=0
    ai=aj=0
    for i in range(n-1,-1,-1):
        x=aa[i]
        if i==n-1:
            ii.append(i)
            xx.append(x)
            continue
        if ii[0]>i+d:
            ii.popleft()
            xx.popleft()
        #print(i,x,ai,aj,mx,ii,xx)
        cur=xx[0]-x
        if cur>=mx:
            mx=cur
            ai=i
            aj=ii[0]
        while xx and xx[-1]<=x:
            ii.pop()
            xx.pop()
        xx.append(x)
        ii.append(i)

    print(mx*k)
    if mx:print(ai,aj)

main()
0