結果

問題 No.3670 Fast Knapsack
コンテスト
ユーザー norioc
提出日時 2026-11-17 01:13:05
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 1,901 ms / 2,500 ms
+ 149µs
コード長 367 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 83 ms
コンパイル使用メモリ 64,360 KB
実行使用メモリ 92,356 KB
最終ジャッジ日時 2026-11-17 01:13:41
合計ジャッジ時間 28,826 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def solve():
    N, S = map(int, input().split())
    A = list(map(int, input().split()))

    mask = (1 << (S+1)) - 1
    b = 1
    for a in A:
        b = mask & (b | (b << a))

    # for i in reversed(range(S+1)):
    #     if b & (1 << i):
    #         return i

    return b.bit_length()-1


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