結果
| 問題 |
No.77 レンガのピラミッド
|
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2016-03-04 19:27:39 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 5,000 ms |
| コード長 | 652 bytes |
| コンパイル時間 | 333 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-09-24 14:10:15 |
| 合計ジャッジ時間 | 1,716 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 20 |
ソースコード
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import array
import itertools
import math
def make_pyramid_seq(index):
sequence = array.array("I", range(1, index + 1))
sequence.extend(range(1, index)[::-1])
return sequence
def solve(given_seq):
given_sum = sum(given_seq)
pyramid_seq = make_pyramid_seq(math.floor(math.sqrt(given_sum)))
zip_iter = itertools.zip_longest(given_seq, pyramid_seq, fillvalue=0)
return sum(max(0, act - ide) for act, ide in zip_iter)
def main():
_ = input()
given_seq = array.array("I", map(int, input().split()))
print(solve(given_seq))
if __name__ == '__main__':
main()
はむ吉🐹