結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-13 18:43:29 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 122 ms / 1,000 ms |
| コード長 | 672 bytes |
| コンパイル時間 | 149 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 20,132 KB |
| 最終ジャッジ日時 | 2024-07-20 00:19:52 |
| 合計ジャッジ時間 | 3,873 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
#!/usr/bin/env python3.8
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque
# %%
N, D, K, *X = map(int, read().split())
# %%
def gen_cand():
q = deque([0])
for k, x in enumerate(X[1:], 1):
while q[0] < k - D:
q.popleft()
j = q[0]
diff = x - X[j]
yield j, k, diff
while q and X[q[-1]] > x:
q.pop()
q.append(k)
# %%
best = 0, 0, 0
for j, k, x in gen_cand():
if best[2] < x:
best = j, k, x
if best[2] == 0:
print(0)
else:
print(best[2] * K)
print(best[0], best[1])
maspy