結果

問題 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  
実行時間 141 ms / 1,000 ms
+ 627µs
コード長 753 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 281 ms
コンパイル使用メモリ 21,156 KB
実行使用メモリ 22,140 KB
最終ジャッジ日時 2026-08-19 05:15:41
合計ジャッジ時間 6,669 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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