結果
問題 | No.393 2本の竹 |
ユーザー |
![]() |
提出日時 | 2023-11-22 08:56:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 544 ms / 1,000 ms |
コード長 | 626 bytes |
コンパイル時間 | 288 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 251,904 KB |
最終ジャッジ日時 | 2024-09-26 07:25:34 |
合計ジャッジ時間 | 6,031 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
import sysinput = sys.stdin.readlinet = int(input())inf = 10 ** 18for _ in range(t):n1, n2 = map(int, input().split())m = int(input())A = sorted(list(map(int, input().split())))pre = [-inf] * (n1 + 1)pre[0] = 0now = 0ans = -1for a in A:dp = [-inf] * (n1 + 1)for i in range(n1 + 1):if i + a <= n1:dp[i + a] = max(dp[i + a], pre[i] + 1)if now - i + a <= n2:dp[i] = max(dp[i], pre[i] + 1)ans = max(ans, max(dp))now += adp, pre = pre, dpprint(ans) if ans != -1 else print(0)