結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー O2MTO2MT
提出日時 2021-02-11 18:01:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 867 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 82,856 KB
実行使用メモリ 352,172 KB
最終ジャッジ日時 2024-07-18 06:25:30
合計ジャッジ時間 27,225 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 2 WA * 23 TLE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
D = list(map(int,input().split()))
D.sort(reverse = True)
M = len(D)
left = 0
right = N+1

def doDP(num):
    dp = [[False for _ in range(N+1)] for _ in range(N+1)]
    count = 0
    for i in range(1,num+1):
        if A[i]+B[0] >= D[i-1]:
            dp[i][0] = True
        else:
            break
    for j in range(1,num+1):
        if A[0]+B[j] >= D[j-1]:
            dp[0][j] = True
        else:
            break
    for i in range(N):
        for j in range(N-i):
            if (D[i+j-1] <= A[i]+B[j]) and (dp[i-1][j] or dp[i][j-1]):
                dp[i][j] = True
                count = max(count,i+j+1)
    return count

while (right-left) > 1:
    mid = (right+left)//2
    c = doDP(mid)
    if left < c:
        left = mid
    else:
        right = mid
print(left)
0