結果

問題 No.1077 Noelちゃんと星々4
ユーザー ytftytft
提出日時 2022-03-22 00:54:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 342 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 82,080 KB
実行使用メモリ 153,784 KB
最終ジャッジ日時 2024-04-17 22:02:44
合計ジャッジ時間 4,561 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
61,072 KB
testcase_01 AC 43 ms
62,692 KB
testcase_02 AC 213 ms
114,132 KB
testcase_03 AC 242 ms
136,268 KB
testcase_04 AC 106 ms
91,216 KB
testcase_05 AC 106 ms
91,012 KB
testcase_06 AC 118 ms
91,132 KB
testcase_07 AC 124 ms
91,276 KB
testcase_08 AC 107 ms
91,216 KB
testcase_09 AC 99 ms
91,696 KB
testcase_10 AC 223 ms
136,216 KB
testcase_11 AC 168 ms
113,720 KB
testcase_12 AC 148 ms
112,628 KB
testcase_13 AC 91 ms
90,036 KB
testcase_14 AC 221 ms
136,124 KB
testcase_15 AC 144 ms
111,424 KB
testcase_16 AC 107 ms
91,408 KB
testcase_17 AC 157 ms
113,884 KB
testcase_18 AC 229 ms
136,212 KB
testcase_19 AC 91 ms
89,212 KB
testcase_20 AC 38 ms
61,188 KB
testcase_21 AC 253 ms
153,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda:sys.stdin.readline().rstrip()
N=int(input())
Y=list(map(int,input().split()))
dp=[[0 for i in range(10001)] for j in range(N)]
for i in range(10001):
	dp[0][i]=max(0,Y[0]-i)
for i in range(1,N):
	dp[i][0]=dp[i-1][0]+Y[i]
	for j in range(1,10001):
		dp[i][j]=min(dp[i][j-1],abs(Y[i]-j)+dp[i-1][j])
print(dp[N-1][10000])
0