結果
| 問題 |
No.393 2本の竹
|
| コンテスト | |
| ユーザー |
tktk_snsn
|
| 提出日時 | 2021-01-14 16:05:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 777 ms / 1,000 ms |
| コード長 | 601 bytes |
| コンパイル時間 | 137 ms |
| コンパイル使用メモリ | 82,560 KB |
| 実行使用メモリ | 257,732 KB |
| 最終ジャッジ日時 | 2024-11-24 06:55:00 |
| 合計ジャッジ時間 | 4,220 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 |
ソースコード
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")
tktk_snsn