結果

問題 No.27 板の準備
ユーザー lloyzlloyz
提出日時 2023-09-26 20:49:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 205 ms / 5,000 ms
コード長 691 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 10,840 KB
実行使用メモリ 8,236 KB
最終ジャッジ日時 2023-09-26 20:49:22
合計ジャッジ時間 4,866 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 205 ms
8,200 KB
testcase_01 AC 174 ms
8,236 KB
testcase_02 AC 179 ms
8,136 KB
testcase_03 AC 177 ms
8,188 KB
testcase_04 AC 175 ms
8,144 KB
testcase_05 AC 176 ms
8,112 KB
testcase_06 AC 177 ms
8,228 KB
testcase_07 AC 181 ms
8,148 KB
testcase_08 AC 182 ms
8,072 KB
testcase_09 AC 183 ms
8,168 KB
testcase_10 AC 179 ms
8,188 KB
testcase_11 AC 187 ms
8,120 KB
testcase_12 AC 184 ms
8,136 KB
testcase_13 AC 180 ms
8,236 KB
testcase_14 AC 175 ms
8,232 KB
testcase_15 AC 175 ms
8,136 KB
testcase_16 AC 181 ms
8,172 KB
testcase_17 AC 177 ms
8,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations

a, b, c, d = map(int, input().split())
INF = 10**18
ans = INF
for C in combinations(range(1, 31), 3):
    x, y, z = C
    DP = [INF for _ in range(31)]
    for i in range(30 // x + 1):
        for j in range(30 // y + 1):
            if x * i + y * j > 30:
                break
            for k in range(30 // z + 1):
                if x * i + y * j + z * k > 30:
                    break
                res = x * i + y * j + z * k
                DP[res] = min(DP[res], i + j + k)
    if DP[a] == INF or DP[b] == INF or DP[c] == INF or DP[d] == INF:
        continue
    ans = min(ans, DP[a] + DP[b] + DP[c] + DP[d])
print(ans)
0