結果

問題 No.842 初詣
ユーザー はむ吉🐹はむ吉🐹
提出日時 2019-06-28 21:35:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 272 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 10,804 KB
実行使用メモリ 8,352 KB
最終ジャッジ日時 2023-09-14 21:40:21
合計ジャッジ時間 2,253 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,344 KB
testcase_01 AC 17 ms
8,304 KB
testcase_02 AC 16 ms
8,220 KB
testcase_03 AC 56 ms
8,252 KB
testcase_04 AC 35 ms
8,188 KB
testcase_05 AC 149 ms
8,328 KB
testcase_06 AC 19 ms
8,108 KB
testcase_07 AC 64 ms
8,176 KB
testcase_08 AC 18 ms
8,216 KB
testcase_09 AC 54 ms
8,352 KB
testcase_10 AC 272 ms
8,112 KB
testcase_11 AC 16 ms
8,152 KB
testcase_12 AC 21 ms
8,336 KB
testcase_13 AC 38 ms
8,344 KB
testcase_14 AC 27 ms
8,252 KB
testcase_15 AC 17 ms
8,180 KB
testcase_16 AC 30 ms
8,156 KB
testcase_17 AC 20 ms
8,284 KB
testcase_18 AC 21 ms
8,252 KB
testcase_19 AC 39 ms
8,348 KB
testcase_20 AC 161 ms
8,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools


COINS = (500, 100, 50, 10, 5, 1)


def solve(a, b, c, d, e, f, g):
    max_nums = (a, b, c, d, e, f)
    num_combis = itertools.product(*(range(max_num + 1) for max_num in max_nums))
    for num_combi in num_combis:
        tot = sum(n * k for n, k in zip(num_combi, COINS))
        if tot == g:
            return True
    else:
        return False


def main():
    a, b, c, d, e, f, g = (int(z) for z in input().split())
    res = solve(a, b, c, d, e, f, g)
    print("YES" if res else "NO")


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