結果

問題 No.27 板の準備
ユーザー 👑 colognecologne
提出日時 2022-01-23 02:05:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 5,000 ms
コード長 557 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 77,900 KB
最終ジャッジ日時 2023-08-19 02:19:05
合計ジャッジ時間 2,602 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
71,384 KB
testcase_01 AC 58 ms
71,344 KB
testcase_02 AC 88 ms
77,240 KB
testcase_03 AC 64 ms
75,556 KB
testcase_04 AC 91 ms
77,536 KB
testcase_05 AC 82 ms
77,324 KB
testcase_06 AC 92 ms
77,716 KB
testcase_07 AC 99 ms
77,564 KB
testcase_08 AC 102 ms
77,728 KB
testcase_09 AC 95 ms
77,456 KB
testcase_10 AC 93 ms
77,584 KB
testcase_11 AC 83 ms
77,272 KB
testcase_12 AC 92 ms
77,580 KB
testcase_13 AC 88 ms
77,604 KB
testcase_14 AC 80 ms
77,432 KB
testcase_15 AC 97 ms
77,900 KB
testcase_16 AC 70 ms
75,948 KB
testcase_17 AC 97 ms
77,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline


def main():
    x, y, z, w = map(int, input().split())
    M = max(x, y, z, w, 3)
    ans = float('inf')
    for a in range(1, M+1):
        for b in range(1, a):
            for c in range(1, b):
                D = [0] + [float('inf')]*M
                for i in range(M):
                    for j in [a, b, c]:
                        if i+j <= M:
                            D[i+j] = min(D[i+j], D[i]+1)
                ans = min(ans, D[x]+D[y]+D[z]+D[w])
    print(ans)


if __name__ == '__main__':
    main()
0