結果

問題 No.27 板の準備
ユーザー nebukuro09nebukuro09
提出日時 2016-09-28 14:59:06
言語 Python2
(2.7.18)
結果
AC  
実行時間 90 ms / 5,000 ms
コード長 544 bytes
コンパイル時間 48 ms
コンパイル使用メモリ 6,672 KB
実行使用メモリ 6,064 KB
最終ジャッジ日時 2023-08-27 04:36:34
合計ジャッジ時間 2,603 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
5,956 KB
testcase_01 AC 88 ms
5,860 KB
testcase_02 AC 89 ms
6,060 KB
testcase_03 AC 89 ms
6,064 KB
testcase_04 AC 90 ms
5,908 KB
testcase_05 AC 88 ms
5,916 KB
testcase_06 AC 88 ms
5,836 KB
testcase_07 AC 88 ms
5,972 KB
testcase_08 AC 89 ms
5,952 KB
testcase_09 AC 89 ms
6,012 KB
testcase_10 AC 89 ms
5,860 KB
testcase_11 AC 88 ms
5,936 KB
testcase_12 AC 89 ms
5,936 KB
testcase_13 AC 89 ms
5,852 KB
testcase_14 AC 89 ms
5,924 KB
testcase_15 AC 89 ms
5,864 KB
testcase_16 AC 89 ms
5,864 KB
testcase_17 AC 89 ms
5,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

V = map(int, raw_input().split())

def solve(a, b, c):
    dp = [float('inf') for i in xrange(31)]
    dp[0] = 0
    for i in xrange(a, 31):
        if i - a >= 0:
            dp[i] = min(dp[i], dp[i-a]+1)
        if i - b >= 0:
            dp[i] = min(dp[i], dp[i-b]+1)
        if i - c >= 0:
            dp[i] = min(dp[i], dp[i-c]+1)
    return dp[V[0]]+dp[V[1]]+dp[V[2]]+dp[V[3]]

ans = float('inf')
for a in xrange(1, 31):
    for b in xrange(a+1, 31):
        for c in xrange(b+1, 31):
            ans = min(ans, solve(a, b, c))
print ans
0