結果

問題 No.27 板の準備
ユーザー roarisroaris
提出日時 2019-08-21 23:05:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 599 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 77,164 KB
最終ジャッジ日時 2024-04-18 10:35:22
合計ジャッジ時間 2,836 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,224 KB
testcase_01 AC 38 ms
51,968 KB
testcase_02 AC 112 ms
77,016 KB
testcase_03 AC 54 ms
64,896 KB
testcase_04 AC 111 ms
76,428 KB
testcase_05 AC 102 ms
76,416 KB
testcase_06 AC 118 ms
76,876 KB
testcase_07 AC 119 ms
76,940 KB
testcase_08 AC 110 ms
76,696 KB
testcase_09 AC 112 ms
76,960 KB
testcase_10 AC 111 ms
77,164 KB
testcase_11 AC 105 ms
76,516 KB
testcase_12 AC 110 ms
76,872 KB
testcase_13 AC 112 ms
76,624 KB
testcase_14 AC 104 ms
76,632 KB
testcase_15 AC 115 ms
76,896 KB
testcase_16 AC 88 ms
76,360 KB
testcase_17 AC 119 ms
76,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

V = list(map(int, input().split()))
M = max(V)
ans = 10 ** 18

for A in range(1, M+1):
    for B in range(1, M+1):
        for C in range(1, M+1):
            dp = [10**18] * (M+1)
            dp[0] = 0
            
            for i in range(1, M+1):
                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)
                
            ans = min(ans, dp[V[0]] + dp[V[1]] + dp[V[2]] + dp[V[3]])

print(ans)
0