結果
| 問題 |
No.484 収穫
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-04-07 10:21:23 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 505 ms / 3,000 ms |
| コード長 | 811 bytes |
| コンパイル時間 | 70 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 44,632 KB |
| 最終ジャッジ日時 | 2024-07-07 10:55:41 |
| 合計ジャッジ時間 | 14,049 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
N = int(readline())
A = np.array(read().split(), np.int64)
INF = 10 ** 9 * 2
n = 1
dpl = np.array([A[0]], np.int64)
dpr = np.array([A[-1]], np.int64)
for n in range(2, N + 1):
newdpl = np.full(n, INF, np.int64)
np.minimum(newdpl[1:], dpl + 1, out=newdpl[1:])
np.minimum(newdpl[:-1], dpr[::-1] + N - n + 1, out=newdpl[:-1])
np.maximum(newdpl, A[:n], out=newdpl)
newdpr = np.full(n, INF, np.int64)
np.minimum(newdpr[1:], dpr + 1, out=newdpr[1:])
np.minimum(newdpr[:-1], dpl[::-1] + N - n + 1, out=newdpr[:-1])
np.maximum(newdpr, A[::-1][:n], out=newdpr)
dpl, dpr = newdpl, newdpr
answer = np.min(dpl)
print(answer)
maspy