結果

問題 No.393 2本の竹
ユーザー convexineq
提出日時 2020-12-06 23:11:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 41 ms / 1,000 ms
コード長 381 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 82,388 KB
実行使用メモリ 58,596 KB
最終ジャッジ日時 2024-09-17 13:21:16
合計ジャッジ時間 2,268 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n1,n2 = map(int,input().split())
    m = int(input())
    *a, = map(int,input().split())
    a.sort()
    dp = 1
    v = 0
    mask = (1<<(n1+1)) - 1
    for i,ai in enumerate(a):
        v += ai
        dp |= dp<<ai
        dp &= mask
        if v >= n2 and dp < 1<<(v-n2):
            return i
    return m

d = int(input())
for _ in range(d):
    print(solve())
0