結果

問題 No.949 飲酒プログラミングコンテスト
コンテスト
ユーザー face4
提出日時 2019-12-12 11:11:51
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 284 ms / 2,500 ms
コード長 535 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 152 ms
コンパイル使用メモリ 85,572 KB
実行使用メモリ 81,900 KB
最終ジャッジ日時 2026-03-11 01:24:27
合計ジャッジ時間 4,909 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = list(map(int, input().split()))
a.reverse()
b.reverse()
d.sort()
d.append(1<<30)
ans = 0
dp = [0]*(n+1)
for i in range(n+1):
    ndp = [0]*(n+1)
    for j in range(n+1):
        if i+1 <= n:
            ndp[j] = max(ndp[j], dp[j]+(1 if a[i+1]+b[j]>=d[dp[j]] else 0))
        if j+1 <= n:
            dp[j+1] = max(dp[j+1], dp[j]+(1 if a[i]+b[j+1]>=d[dp[j]] else 0))
    ans = max(ans, max(dp[:n+(1 if i != n else 0)]))
    dp = ndp
print(ans)
0