結果

問題 No.27 板の準備
ユーザー H3PO4H3PO4
提出日時 2020-04-19 11:20:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 196 ms / 5,000 ms
コード長 439 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-15 06:51:02
合計ジャッジ時間 2,579 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 29 ms
10,880 KB
testcase_04 AC 99 ms
11,008 KB
testcase_05 AC 63 ms
11,136 KB
testcase_06 AC 111 ms
11,008 KB
testcase_07 AC 175 ms
11,136 KB
testcase_08 AC 196 ms
11,136 KB
testcase_09 AC 173 ms
11,136 KB
testcase_10 AC 157 ms
11,136 KB
testcase_11 AC 78 ms
11,136 KB
testcase_12 AC 110 ms
11,136 KB
testcase_13 AC 98 ms
11,008 KB
testcase_14 AC 70 ms
11,136 KB
testcase_15 AC 156 ms
11,008 KB
testcase_16 AC 35 ms
11,008 KB
testcase_17 AC 194 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
from sys import exit

V = set(map(int, input().split()))
if len(V) <= 3:
    print(4)
    exit()

MV = max(V)
ans = float('inf')
for T in itertools.combinations(range(1, MV + 1), 3):
    table = [float('inf')] * (MV + 1)
    table[0] = 0
    for i in range(MV + 1):
        if bef := tuple(table[i - t] + 1 for t in T if i - t >= 0):
            table[i] = min(bef)
    ans = min(ans, sum(table[v] for v in V))
print(ans)
0