結果
問題 | No.393 2本の竹 |
ユーザー |
![]() |
提出日時 | 2019-01-09 23:21:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 330 ms / 1,000 ms |
コード長 | 700 bytes |
コンパイル時間 | 388 ms |
コンパイル使用メモリ | 82,232 KB |
実行使用メモリ | 80,008 KB |
最終ジャッジ日時 | 2024-11-24 01:00:59 |
合計ジャッジ時間 | 3,873 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
N = int(input())for i in range(N):n1, n2 = sorted(list(map(int, input().split(' '))))m = int(input())fragments = sorted(list(map(int, input().split(' '))))acc = 0count = 0while count < m and acc + fragments[count] <= n1 + n2:acc = acc + fragments[count]count = count + 1dp = [False for _ in range(n1+1)]dp[0] = Truefor i in range(count):for j in reversed(range(n1)):if dp[j]:if j + fragments[i] < n1+1:dp[j + fragments[i]] = Truelast = n1while not dp[last]:last = last - 1found = (acc - last <= n2)print(count - (0 if found else 1))