結果

問題 No.27 板の準備
ユーザー chocoruskchocorusk
提出日時 2020-09-08 11:04:11
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 150 ms / 5,000 ms
コード長 518 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 10,988 KB
実行使用メモリ 7,912 KB
最終ジャッジ日時 2023-08-19 17:34:33
合計ジャッジ時間 3,100 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,780 KB
testcase_01 AC 16 ms
7,828 KB
testcase_02 AC 136 ms
7,816 KB
testcase_03 AC 16 ms
7,780 KB
testcase_04 AC 74 ms
7,772 KB
testcase_05 AC 45 ms
7,768 KB
testcase_06 AC 82 ms
7,772 KB
testcase_07 AC 133 ms
7,876 KB
testcase_08 AC 150 ms
7,868 KB
testcase_09 AC 137 ms
7,828 KB
testcase_10 AC 119 ms
7,880 KB
testcase_11 AC 57 ms
7,752 KB
testcase_12 AC 85 ms
7,808 KB
testcase_13 AC 74 ms
7,776 KB
testcase_14 AC 51 ms
7,740 KB
testcase_15 AC 121 ms
7,780 KB
testcase_16 AC 20 ms
7,912 KB
testcase_17 AC 150 ms
7,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

v=list(map(int, input().split()))
m=max(v)
INF=1000
ans=INF
for a in range(1, m+1):
    for b in range(1, a+1):
        for c in range(1, b+1):
            dp=[INF]*(m+1)
            dp[0]=0
            for i in range(1, m+1):
                if i>=a:
                    dp[i]=min(dp[i], dp[i-a]+1)
                if i>=b:
                    dp[i]=min(dp[i], dp[i-b]+1)
                if i>=c:
                    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