結果

問題 No.27 板の準備
ユーザー ayaoniayaoni
提出日時 2020-12-04 13:17:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 161 ms / 5,000 ms
コード長 941 bytes
コンパイル時間 765 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 77,928 KB
最終ジャッジ日時 2023-10-13 01:32:02
合計ジャッジ時間 4,386 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
77,544 KB
testcase_01 AC 161 ms
77,864 KB
testcase_02 AC 161 ms
77,876 KB
testcase_03 AC 161 ms
77,588 KB
testcase_04 AC 159 ms
77,752 KB
testcase_05 AC 159 ms
77,700 KB
testcase_06 AC 160 ms
77,720 KB
testcase_07 AC 159 ms
77,820 KB
testcase_08 AC 159 ms
77,640 KB
testcase_09 AC 159 ms
77,928 KB
testcase_10 AC 161 ms
77,640 KB
testcase_11 AC 161 ms
77,752 KB
testcase_12 AC 161 ms
77,640 KB
testcase_13 AC 161 ms
77,796 KB
testcase_14 AC 159 ms
77,812 KB
testcase_15 AC 160 ms
77,664 KB
testcase_16 AC 157 ms
77,576 KB
testcase_17 AC 157 ms
77,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


x,y,z,w = MI()
inf = 10**18
ans = inf
for i in range(1,31):
    for j in range(1,31):
        for k in range(1,31):
            dp = [inf]*31
            dp[0] = 0
            for l in range(1,31):
                if l >= i:
                    dp[l] = min(dp[l],dp[l-i]+1)
                if l >= j:
                    dp[l] = min(dp[l],dp[l-j]+1)
                if l >= k:
                    dp[l] = min(dp[l],dp[l-k]+1)
            ans = min(ans,dp[x]+dp[y]+dp[z]+dp[w])

print(ans)
0