結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー mkawa2mkawa2
提出日時 2021-03-24 23:59:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,066 ms / 2,500 ms
コード長 1,296 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 255,720 KB
最終ジャッジ日時 2023-08-17 22:48:21
合計ジャッジ時間 17,336 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,256 KB
testcase_01 AC 71 ms
71,084 KB
testcase_02 AC 73 ms
71,380 KB
testcase_03 AC 73 ms
71,284 KB
testcase_04 AC 73 ms
71,356 KB
testcase_05 AC 71 ms
71,224 KB
testcase_06 AC 73 ms
71,332 KB
testcase_07 AC 73 ms
71,468 KB
testcase_08 AC 89 ms
81,064 KB
testcase_09 AC 74 ms
72,448 KB
testcase_10 AC 80 ms
78,260 KB
testcase_11 AC 543 ms
226,748 KB
testcase_12 AC 446 ms
229,956 KB
testcase_13 AC 469 ms
255,720 KB
testcase_14 AC 118 ms
137,520 KB
testcase_15 AC 801 ms
248,544 KB
testcase_16 AC 1,659 ms
205,656 KB
testcase_17 AC 120 ms
148,444 KB
testcase_18 AC 447 ms
211,808 KB
testcase_19 AC 821 ms
228,140 KB
testcase_20 AC 244 ms
148,848 KB
testcase_21 AC 126 ms
102,512 KB
testcase_22 AC 156 ms
148,816 KB
testcase_23 AC 79 ms
79,444 KB
testcase_24 AC 271 ms
224,180 KB
testcase_25 AC 798 ms
218,648 KB
testcase_26 AC 460 ms
218,512 KB
testcase_27 AC 1,944 ms
218,644 KB
testcase_28 AC 428 ms
218,468 KB
testcase_29 AC 1,580 ms
218,552 KB
testcase_30 AC 870 ms
218,200 KB
testcase_31 AC 443 ms
217,000 KB
testcase_32 AC 2,066 ms
218,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

n = II()
aa = LI()
bb = LI()
dd = LI()
dd.sort(reverse=True)

def ok(m):
    stack = [(0, 0, m)]
    fin = [False]*(n+1)*(n+1)
    while stack:
        i, j, k = stack.pop()
        if k == n: return True
        if aa[i+1]+bb[j] >= dd[k] and not fin[(i+1)*(n+1)+j]:
            fin[(i+1)*(n+1)+j] = True
            stack.append((i+1, j, k+1))
        if aa[i]+bb[j+1] >= dd[k] and not fin[i*(n+1)+j+1]:
            fin[i*(n+1)+j+1] = True
            stack.append((i, j+1, k+1))
    return False

l, r = -1, n
while l+1 < r:
    m = (l+r)//2
    if ok(m): r = m
    else: l = m

print(n-r)
0