結果

問題 No.393 2本の竹
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-14 16:05:39
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 775 ms / 1,000 ms
コード長 601 bytes
コンパイル時間 389 ms
使用メモリ 263,772 KB
最終ジャッジ日時 2022-12-29 04:52:57
合計ジャッジ時間 5,877 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 88 ms
80,748 KB
testcase_01 AC 71 ms
75,680 KB
testcase_02 AC 81 ms
80,612 KB
testcase_03 AC 82 ms
80,788 KB
testcase_04 AC 79 ms
80,580 KB
testcase_05 AC 82 ms
80,676 KB
testcase_06 AC 74 ms
80,428 KB
testcase_07 AC 83 ms
80,792 KB
testcase_08 AC 87 ms
81,160 KB
testcase_09 AC 775 ms
260,680 KB
testcase_10 AC 92 ms
84,500 KB
testcase_11 AC 182 ms
122,136 KB
testcase_12 AC 264 ms
154,440 KB
testcase_13 AC 143 ms
97,728 KB
testcase_14 AC 96 ms
82,544 KB
testcase_15 AC 74 ms
80,428 KB
testcase_16 AC 78 ms
80,596 KB
testcase_17 AC 87 ms
80,664 KB
testcase_18 AC 83 ms
80,372 KB
testcase_19 AC 73 ms
75,464 KB
testcase_20 AC 80 ms
80,424 KB
testcase_21 AC 87 ms
80,612 KB
testcase_22 AC 328 ms
165,668 KB
testcase_23 AC 121 ms
99,756 KB
testcase_24 AC 86 ms
80,380 KB
testcase_25 AC 81 ms
80,652 KB
testcase_26 AC 72 ms
75,776 KB
testcase_27 AC 664 ms
263,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
b = 10 ** 9 + 7


def test():
    x, y = map(int, input().split())
    m = int(input())
    A = sorted(map(int, input().split()))

    dp = {x * b + y}
    for i, a in enumerate(A):
        ndp = set()
        for xy in dp:
            x, y = divmod(xy, b)
            if x - a >= 0:
                ndp.add((x - a) * b + y)
            if y - a >= 0:
                ndp.add(x * b + y - a)
        if not ndp:
            return i
        dp = ndp
    return m


d = int(input())
print(*[test() for _ in range(d)], sep="\n")
0