結果

問題 No.949 飲酒プログラミングコンテスト
コンテスト
ユーザー H3PO4
提出日時 2021-07-18 09:35:02
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 1,380 ms / 2,500 ms
コード長 682 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 221 ms
コンパイル使用メモリ 85,376 KB
実行使用メモリ 392,800 KB
最終ジャッジ日時 2026-03-29 18:45:04
合計ジャッジ時間 15,927 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
D = sorted(map(int, input().split()))


def isOK(x):
    dp = [[False] * (N + 1) for _ in range(N + 1)]
    dp[0][0] = True
    for a in range(N + 1):
        for b in range(x - a + 1):
            if a == b == 0:
                continue
            if A[a] + B[b] >= D[x - a - b]:
                if (a and dp[a - 1][b]) or (b and dp[a][b - 1]):
                    dp[a][b] = True
                    if a + b == x:
                        return True
    return False


l, r = 0, N + 1
while r - l > 1:
    m = (r + l) // 2
    if isOK(m):
        l = m
    else:
        r = m
print(l)
0