結果

問題 No.393 2本の竹
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-14 16:05:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 827 ms / 1,000 ms
コード長 601 bytes
コンパイル時間 403 ms
コンパイル使用メモリ 87,312 KB
実行使用メモリ 259,724 KB
最終ジャッジ日時 2023-08-15 22:01:10
合計ジャッジ時間 6,165 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
76,032 KB
testcase_01 AC 74 ms
71,416 KB
testcase_02 AC 86 ms
75,844 KB
testcase_03 AC 86 ms
76,124 KB
testcase_04 AC 82 ms
75,828 KB
testcase_05 AC 85 ms
76,004 KB
testcase_06 AC 79 ms
75,984 KB
testcase_07 AC 88 ms
76,176 KB
testcase_08 AC 92 ms
76,424 KB
testcase_09 AC 827 ms
256,132 KB
testcase_10 AC 98 ms
79,684 KB
testcase_11 AC 197 ms
117,088 KB
testcase_12 AC 282 ms
147,456 KB
testcase_13 AC 149 ms
93,224 KB
testcase_14 AC 100 ms
78,220 KB
testcase_15 AC 80 ms
76,032 KB
testcase_16 AC 83 ms
76,088 KB
testcase_17 AC 89 ms
75,976 KB
testcase_18 AC 84 ms
76,016 KB
testcase_19 AC 74 ms
71,496 KB
testcase_20 AC 79 ms
75,984 KB
testcase_21 AC 85 ms
76,408 KB
testcase_22 AC 339 ms
162,296 KB
testcase_23 AC 124 ms
93,952 KB
testcase_24 AC 86 ms
76,204 KB
testcase_25 AC 81 ms
76,000 KB
testcase_26 AC 74 ms
71,108 KB
testcase_27 AC 721 ms
259,724 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