結果

問題 No.2150 Site Supporter
ユーザー 👑 KazunKazun
提出日時 2022-12-07 00:09:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 917 ms / 2,000 ms
コード長 876 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 121,716 KB
最終ジャッジ日時 2024-04-21 12:47:38
合計ジャッジ時間 8,453 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
52,224 KB
testcase_01 AC 49 ms
52,608 KB
testcase_02 AC 50 ms
52,096 KB
testcase_03 AC 50 ms
52,480 KB
testcase_04 AC 50 ms
52,352 KB
testcase_05 AC 51 ms
52,480 KB
testcase_06 AC 50 ms
52,224 KB
testcase_07 AC 50 ms
52,480 KB
testcase_08 AC 252 ms
83,032 KB
testcase_09 AC 632 ms
109,948 KB
testcase_10 AC 384 ms
95,744 KB
testcase_11 AC 917 ms
106,912 KB
testcase_12 AC 306 ms
89,984 KB
testcase_13 AC 357 ms
85,504 KB
testcase_14 AC 50 ms
52,608 KB
testcase_15 AC 50 ms
52,224 KB
testcase_16 AC 49 ms
52,480 KB
testcase_17 AC 582 ms
121,716 KB
testcase_18 AC 339 ms
91,904 KB
testcase_19 AC 244 ms
81,816 KB
testcase_20 AC 589 ms
100,800 KB
testcase_21 AC 236 ms
80,324 KB
testcase_22 AC 618 ms
110,004 KB
testcase_23 AC 47 ms
52,480 KB
testcase_24 AC 47 ms
52,480 KB
testcase_25 AC 47 ms
52,224 KB
testcase_26 AC 46 ms
52,352 KB
testcase_27 AC 279 ms
97,024 KB
testcase_28 AC 352 ms
97,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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())
0