結果

問題 No.393 2本の竹
ユーザー fumofumofunifumofumofuni
提出日時 2021-09-13 20:02:32
言語 PyPy3
(7.3.8)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 526 bytes
コンパイル時間 334 ms
使用メモリ 264,520 KB
最終ジャッジ日時 2023-01-24 04:53:12
合計ジャッジ時間 14,746 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 433 ms
262,792 KB
testcase_01 AC 200 ms
191,676 KB
testcase_02 AC 417 ms
263,216 KB
testcase_03 AC 406 ms
263,260 KB
testcase_04 AC 240 ms
232,356 KB
testcase_05 AC 297 ms
263,068 KB
testcase_06 AC 233 ms
223,080 KB
testcase_07 AC 478 ms
263,228 KB
testcase_08 AC 635 ms
263,260 KB
testcase_09 TLE -
testcase_10 AC 368 ms
262,896 KB
testcase_11 AC 577 ms
263,080 KB
testcase_12 AC 577 ms
263,268 KB
testcase_13 AC 570 ms
263,424 KB
testcase_14 AC 487 ms
263,408 KB
testcase_15 AC 317 ms
241,904 KB
testcase_16 AC 410 ms
262,900 KB
testcase_17 AC 382 ms
262,968 KB
testcase_18 AC 248 ms
240,152 KB
testcase_19 AC 153 ms
148,404 KB
testcase_20 AC 227 ms
221,372 KB
testcase_21 AC 331 ms
263,000 KB
testcase_22 AC 533 ms
262,844 KB
testcase_23 AC 566 ms
262,828 KB
testcase_24 AC 339 ms
262,904 KB
testcase_25 AC 281 ms
262,968 KB
testcase_26 AC 189 ms
180,948 KB
testcase_27 AC 907 ms
263,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    N,M=map(int,input().split())
    K=int(input())
    A=list(map(int,input().split()))
    list.sort(A)
    maxN=100010
    dp=[0]*maxN
    dp[0]=1
    ans=0
    cum=0
    for i in range(K):
        cum+=A[i]
        ndp=dp[:]
        for j in range(maxN):
            if dp[j] and j+A[i]<maxN:
                ndp[j+A[i]]=1
        dp=ndp[:]
        for j in range(maxN):
            if dp[j] and j<=N and cum-j<=M:
                ans=max(ans,i+1)
    print(ans)

d=int(input())
while d:
    solve()
    d-=1
0