結果
問題 |
No.393 2本の竹
|
ユーザー |
![]() |
提出日時 | 2016-07-14 17:45:55 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 855 bytes |
コンパイル時間 | 92 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 17,952 KB |
最終ジャッジ日時 | 2024-10-15 01:10:00 |
合計ジャッジ時間 | 3,317 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 TLE * 1 -- * 18 |
ソースコード
#!/usr/bin/env python3 # after reading the editorials import array UNDEF = -1 def solve(n1, n2, m, xs0): xs = sorted(xs0) dp = [array.array("i", (UNDEF for _ in range(n1 + 1))) for _ in range(m + 1)] dp[0][0] = 0 s = 0 for i in range(m): for j in range(n1 + 1): if dp[i][j] >= 0: c1 = j + xs[i] c2 = s - j + xs[i] if c1 <= n1: dp[i + 1][c1] = dp[i][j] + 1 if c2 <= n2: dp[i + 1][j] = dp[i][j] + 1 s += xs[i] return max(max(dpr) for dpr in dp) def main(): d = int(input()) for _ in range(d): n1, n2 = map(int, input().split()) m = int(input()) xs = map(int, input().split()) print(solve(n1, n2, m, xs)) if __name__ == '__main__': main()