結果

問題 No.393 2本の竹
コンテスト
ユーザー tktk_snsn
提出日時 2021-01-14 16:05:39
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 518 ms / 1,000 ms
コード長 601 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 141 ms
コンパイル使用メモリ 85,376 KB
実行使用メモリ 253,568 KB
最終ジャッジ日時 2026-05-18 05:53:46
合計ジャッジ時間 3,787 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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