結果
問題 | No.393 2本の竹 |
ユーザー | rlangevin |
提出日時 | 2023-11-22 12:24:39 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 747 bytes |
コンパイル時間 | 342 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 84,224 KB |
最終ジャッジ日時 | 2024-09-26 07:28:36 |
合計ジャッジ時間 | 4,629 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 4 |
ソースコード
import sys input = sys.stdin.readline def check(m, A, n1, n2): s = sum(A[:m]) if s > n1 + n2: return False dp = [0] * (n1 + 1) dp[0] = 1 for a in A: for i in range(n1, -1, -1): if i + a > n1: continue dp[i + a] |= dp[i] for i in range(n1 + 1): if dp[i] and s - i <= n2: return True return False t = int(input()) inf = 10 ** 18 for _ in range(t): n1, n2 = map(int, input().split()) m = int(input()) A = sorted(list(map(int, input().split()))) yes = 0 no = m + 1 while no - yes != 1: mid = (yes + no)//2 if check(mid, A, n1, n2): yes = mid else: no = mid print(yes)