結果
問題 | No.77 レンガのピラミッド |
ユーザー |
![]() |
提出日時 | 2016-05-13 05:43:53 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 27 ms / 5,000 ms |
コード長 | 592 bytes |
コンパイル時間 | 102 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-10-05 14:12:50 |
合計ジャッジ時間 | 2,042 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
n = int(input()) b = list(map(int, input().split())) i = 1 p = 1 while True: i = i + 1 p = i * i if p > sum(b): i = i - 1 p = i * i break to_top = [x for x in range(1, i+1)] to_bottom = [y for y in range(i-1, 0, -1)] pyramid = to_top + to_bottom if len(pyramid) < len(b): pyramid = pyramid + [0] * (len(b)-len(pyramid)) if len(b) < len(pyramid): b = b + [0] * (len(pyramid)-len(b)) pb = 0 mb = 0 for j, k in zip(pyramid,b): if k > j: mb += k - j elif j > k: pb += j - k if sum(b) > p: print(mb) else: print(pb)