結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー maspy
提出日時 2020-03-18 02:06:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 338 ms / 2,500 ms
コード長 1,058 bytes
コンパイル時間 957 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 71,652 KB
最終ジャッジ日時 2024-11-30 23:40:16
合計ジャッジ時間 5,119 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3.8
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# %%
N = int(readline())
A = tuple(map(int, readline().split()))
B = tuple(map(int, readline().split()))
D = tuple(sorted(map(int, readline().split())))

# %%


def test(n):
    difficulty = D[:n][::-1]
    dp = [0] * (n + 1)
    dp[0] = 1
    for j in range(1, n + 1):
        if A[0] + B[j] >= difficulty[j - 1]:
            dp[j] = 1
        else:
            break
    if dp[-1]:
        return True
    for i in range(1, n + 1):
        dp.pop()
        for j in range(n - i + 1):
            if not dp[j]:
                continue
            if A[i] + B[j] < difficulty[i + j - 1]:
                dp[j] = 0
                continue
            if j < n - i:
                dp[j + 1] = 1
        if dp[-1]:
            return True
    return False


# %%
left = 0
right = N + 1
while left + 1 < right:
    x = (left + right) // 2
    if test(x):
        left = x
    else:
        right = x
print(left)
0