結果

問題 No.393 2本の竹
ユーザー roarisroaris
提出日時 2019-12-13 00:24:26
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 702 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 87,304 KB
実行使用メモリ 260,212 KB
最終ジャッジ日時 2023-09-08 07:50:00
合計ジャッジ時間 9,718 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
76,808 KB
testcase_01 AC 89 ms
76,184 KB
testcase_02 AC 102 ms
76,932 KB
testcase_03 AC 101 ms
76,828 KB
testcase_04 AC 90 ms
76,172 KB
testcase_05 AC 96 ms
76,224 KB
testcase_06 AC 91 ms
76,508 KB
testcase_07 AC 110 ms
77,280 KB
testcase_08 AC 138 ms
78,516 KB
testcase_09 TLE -
testcase_10 AC 443 ms
142,640 KB
testcase_11 AC 540 ms
156,784 KB
testcase_12 AC 568 ms
165,112 KB
testcase_13 AC 406 ms
135,016 KB
testcase_14 AC 303 ms
113,848 KB
testcase_15 AC 219 ms
100,120 KB
testcase_16 AC 402 ms
144,708 KB
testcase_17 AC 99 ms
76,296 KB
testcase_18 AC 96 ms
76,368 KB
testcase_19 AC 86 ms
76,412 KB
testcase_20 AC 89 ms
76,456 KB
testcase_21 AC 98 ms
76,772 KB
testcase_22 AC 640 ms
183,184 KB
testcase_23 AC 403 ms
113,648 KB
testcase_24 AC 119 ms
77,344 KB
testcase_25 AC 111 ms
77,428 KB
testcase_26 AC 86 ms
76,152 KB
testcase_27 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

d = int(input())

for _ in range(d):
    n1, n2 = map(int, input().split())
    m = int(input())
    A = list(map(int, input().split()))
    A.sort()
    dp = [[False]*(n1+1) for _ in range(m+1)]
    dp[0][0] = True
    acc = 0
    
    for i in range(m):
        for j in range(n1+1):
            if j+A[i]<=n1:
                dp[i+1][j+A[i]] |= dp[i][j]
            
            n2_used = acc-j
            
            if n2_used+A[i]<=n2:
                dp[i+1][j] |= dp[i][j]
            
        acc += A[i]
    
    for i in range(m, -1, -1):
        for j in range(n1+1):
            if dp[i][j]:
                print(i)
                break
        else:
            continue
        break
0