結果

問題 No.77 レンガのピラミッド
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-03-04 19:27:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 30 ms / 5,000 ms
コード長 652 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 12,004 KB
実行使用メモリ 10,336 KB
最終ジャッジ日時 2023-10-24 19:49:29
合計ジャッジ時間 1,776 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,332 KB
testcase_01 AC 30 ms
10,332 KB
testcase_02 AC 29 ms
10,332 KB
testcase_03 AC 29 ms
10,332 KB
testcase_04 AC 29 ms
10,332 KB
testcase_05 AC 29 ms
10,332 KB
testcase_06 AC 30 ms
10,336 KB
testcase_07 AC 29 ms
10,332 KB
testcase_08 AC 30 ms
10,336 KB
testcase_09 AC 29 ms
10,332 KB
testcase_10 AC 29 ms
10,332 KB
testcase_11 AC 30 ms
10,332 KB
testcase_12 AC 30 ms
10,336 KB
testcase_13 AC 29 ms
10,336 KB
testcase_14 AC 29 ms
10,336 KB
testcase_15 AC 30 ms
10,332 KB
testcase_16 AC 30 ms
10,332 KB
testcase_17 AC 29 ms
10,332 KB
testcase_18 AC 29 ms
10,336 KB
testcase_19 AC 29 ms
10,332 KB
testcase_20 AC 29 ms
10,332 KB
testcase_21 AC 29 ms
10,332 KB
testcase_22 AC 29 ms
10,332 KB
testcase_23 AC 29 ms
10,332 KB
testcase_24 AC 29 ms
10,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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()
0