結果
| 問題 |
No.77 レンガのピラミッド
|
| コンテスト | |
| ユーザー |
takakin
|
| 提出日時 | 2020-05-16 17:58:24 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 5,000 ms |
| コード長 | 472 bytes |
| コンパイル時間 | 105 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-09-22 14:17:24 |
| 合計ジャッジ時間 | 1,788 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 20 |
ソースコード
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
A+=[0 for i in range(n)]
ans=sum(A)
for i in range(n):
pos,neg=0,0
for j in range(2*n):
if j<=i:
if A[j]>=j+1:
pos+=A[j]-(j+1)
else:
neg+=(j+1)-A[j]
elif j<=2*i:
if A[j]>=2*i+1-j:
pos+=A[j]-(2*i+1-j)
else:
neg+=(2*i+1-j)-A[j]
else:
pos+=A[j]
if pos>=neg:
ans=min(ans,pos)
print(ans)
takakin