結果

問題 No.27 板の準備
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-08-10 15:08:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 107 ms / 5,000 ms
コード長 666 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-08-27 04:31:39
合計ジャッジ時間 3,042 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
8,600 KB
testcase_01 AC 102 ms
8,644 KB
testcase_02 AC 104 ms
8,600 KB
testcase_03 AC 107 ms
8,768 KB
testcase_04 AC 104 ms
8,588 KB
testcase_05 AC 102 ms
8,684 KB
testcase_06 AC 102 ms
8,588 KB
testcase_07 AC 102 ms
8,712 KB
testcase_08 AC 103 ms
8,704 KB
testcase_09 AC 104 ms
8,604 KB
testcase_10 AC 104 ms
8,704 KB
testcase_11 AC 102 ms
8,600 KB
testcase_12 AC 103 ms
8,708 KB
testcase_13 AC 103 ms
8,600 KB
testcase_14 AC 103 ms
8,652 KB
testcase_15 AC 101 ms
8,748 KB
testcase_16 AC 103 ms
8,680 KB
testcase_17 AC 104 ms
8,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

import array
import itertools


INF = 10 ** 8
MAX_LEN = 30
NUM_BOARDS = 3


def compute_minimum(targets, boards):
    dp = array.array("L", (INF for _ in range(MAX_LEN + 1)))
    dp[0] = 0
    for board in boards:
        for i in range(board, MAX_LEN + 1):
            dp[i] = min(dp[i], dp[i - board] + 1)
    return sum(dp[target] for target in targets)


def solve(targets):
    gen = itertools.combinations(range(1, MAX_LEN + 1), 3)
    return min(compute_minimum(targets, boards) for boards in gen)


def main():
    targets = array.array("B", map(int, input().split()))
    print(solve(targets))


if __name__ == '__main__':
    main()
0