結果

問題 No.489 株に挑戦
コンテスト
ユーザー mkawa2
提出日時 2020-05-16 17:42:46
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 263 ms / 1,000 ms
コード長 753 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 361 ms
コンパイル使用メモリ 20,572 KB
実行使用メモリ 38,072 KB
最終ジャッジ日時 2026-04-02 19:04:23
合計ジャッジ時間 9,650 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge5_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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