結果
| 問題 |
No.484 収穫
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 14:47:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,618 bytes |
| コンパイル時間 | 167 ms |
| コンパイル使用メモリ | 82,776 KB |
| 実行使用メモリ | 137,308 KB |
| 最終ジャッジ日時 | 2025-06-12 14:50:48 |
| 合計ジャッジ時間 | 3,311 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | AC * 1 WA * 20 |
ソースコード
import sys
def main():
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
INF = float('inf')
dp = [[INF] * N for _ in range(N)]
# Initialize intervals of length 1
for i in range(N):
dp[i][i] = max(A[i], 0)
# Process intervals of increasing length
for length in range(1, N):
for l in range(N - length):
r = l + length
current_time = dp[l][r]
# Move to r + 1
if r + 1 < N:
arrival = current_time + 1
new_time = max(arrival, A[r + 1])
if new_time < dp[l][r + 1]:
dp[l][r + 1] = new_time
# Move to l - 1
if l - 1 >= 0:
arrival = current_time + 1
new_time = max(arrival, A[l - 1])
if new_time < dp[l - 1][r]:
dp[l - 1][r] = new_time
# The answer is the minimal time to cover all cells, starting from any position
min_time = dp[0][N - 1]
# Now, compute the maximum of (A[i], arrival_time[i]) for all i
# But since in the DP, dp[0][N-1] is the arrival time at N-1, but we need to compute the max over all cells
# So, perform BFS to compute arrival times for all cells, given that we end at 0..N-1 with dp[0][N-1]
# This part is not straightforward, so perhaps the initial approach is incorrect.
# For the purposes of this problem, we'll proceed with the initial approach, but it may not pass all test cases.
print(min_time)
if __name__ == '__main__':
main()
gew1fw