結果

問題 No.393 2本の竹
ユーザー fumofumofunifumofumofuni
提出日時 2021-09-13 20:02:32
言語 PyPy3
(7.3.13)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 526 bytes
コンパイル時間 1,145 ms
コンパイル使用メモリ 86,692 KB
実行使用メモリ 260,192 KB
最終ジャッジ日時 2023-09-08 03:40:25
合計ジャッジ時間 14,902 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 427 ms
259,056 KB
testcase_01 AC 194 ms
187,172 KB
testcase_02 AC 419 ms
259,292 KB
testcase_03 AC 400 ms
259,316 KB
testcase_04 AC 232 ms
227,576 KB
testcase_05 AC 304 ms
259,176 KB
testcase_06 AC 234 ms
218,544 KB
testcase_07 AC 477 ms
259,208 KB
testcase_08 AC 623 ms
259,424 KB
testcase_09 TLE -
testcase_10 AC 367 ms
259,312 KB
testcase_11 AC 604 ms
259,320 KB
testcase_12 AC 591 ms
259,212 KB
testcase_13 AC 575 ms
259,288 KB
testcase_14 AC 486 ms
259,432 KB
testcase_15 AC 314 ms
237,324 KB
testcase_16 AC 406 ms
259,292 KB
testcase_17 AC 382 ms
259,344 KB
testcase_18 AC 246 ms
235,832 KB
testcase_19 AC 151 ms
143,956 KB
testcase_20 AC 221 ms
217,084 KB
testcase_21 AC 331 ms
259,484 KB
testcase_22 AC 539 ms
259,024 KB
testcase_23 AC 542 ms
259,204 KB
testcase_24 AC 332 ms
259,236 KB
testcase_25 AC 288 ms
259,324 KB
testcase_26 AC 192 ms
176,096 KB
testcase_27 AC 947 ms
259,480 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