結果

問題 No.393 2本の竹
ユーザー rpy3cpp
提出日時 2016-07-14 01:59:08
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 792 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 15,872 KB
最終ジャッジ日時 2024-10-15 01:09:12
合計ジャッジ時間 3,063 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    n1, n2 = map(int, input().split())
    m = int(input())
    As = list(map(int, input().split()))
    return n1, n2, m, As

def solve(n1, n2, m, As):
    As.sort()
    cum = 0
    n12 = n1 + n2
    ans = 0
    dp = [0] * (n1 + 1)
    dp[0] = 1
    for a in As:
        cum += a
        if cum > n12:
            return ans
        for pos in range(n1, a - 1, -1):
            if dp[pos - a]:
                dp[pos] = 1
        for pos in range(n1, -1, -1):
            if dp[pos]:
                if pos + n2 < cum:
                    return ans
                else:
                    break
        ans += 1
    return ans

if __name__ == '__main__':
    d = int(input())
    for i in range(d):
        n1, n2, m, As = read_data()
        print(solve(n1, n2, m, As))
0