結果
| 問題 |
No.2150 Site Supporter
|
| コンテスト | |
| ユーザー |
👑 Kazun
|
| 提出日時 | 2022-12-07 00:09:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 840 ms / 2,000 ms |
| コード長 | 876 bytes |
| コンパイル時間 | 392 ms |
| コンパイル使用メモリ | 82,396 KB |
| 実行使用メモリ | 121,480 KB |
| 最終ジャッジ日時 | 2024-10-13 11:18:29 |
| 合計ジャッジ時間 | 7,456 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
def solve():
from heapq import heapify, heappop, heappush
N,K,X=map(int,input().split())
A=list(map(int,input().split()))
inf=float("inf")
T=[[inf, inf] for _ in range(N+1)]
T[0][0]=0
Q=[(0,0,0)]
while Q:
cost,day,mode=heappop(Q)
if day==N:
return cost
if mode==0:
if cost+X<T[day][1]:
T[day][1]=cost+X
heappush(Q,(cost+X,day,1))
if cost+A[day]<T[day+1][0]:
T[day+1][0]=cost+A[day]
heappush(Q,(cost+A[day],day+1,0))
else:
if cost+K<T[day+1][1]:
T[day+1][1]=cost+K
heappush(Q,(cost+K,day+1,1))
if cost<T[day][0]:
T[day][0]=cost
heappush(Q,(cost,day,0))
#==================================================
print(solve())
Kazun