結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー mkawa2mkawa2
提出日時 2021-03-25 00:05:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,384 ms / 2,500 ms
コード長 1,351 bytes
コンパイル時間 416 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 256,956 KB
最終ジャッジ日時 2023-08-17 22:49:19
合計ジャッジ時間 19,726 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,728 KB
testcase_01 AC 94 ms
71,772 KB
testcase_02 AC 96 ms
71,796 KB
testcase_03 AC 94 ms
71,620 KB
testcase_04 AC 95 ms
71,736 KB
testcase_05 AC 96 ms
71,776 KB
testcase_06 AC 95 ms
71,848 KB
testcase_07 AC 96 ms
72,460 KB
testcase_08 AC 113 ms
80,472 KB
testcase_09 AC 94 ms
72,588 KB
testcase_10 AC 103 ms
78,664 KB
testcase_11 AC 651 ms
227,704 KB
testcase_12 AC 476 ms
230,676 KB
testcase_13 AC 526 ms
256,956 KB
testcase_14 AC 146 ms
138,740 KB
testcase_15 AC 894 ms
250,148 KB
testcase_16 AC 1,896 ms
206,504 KB
testcase_17 AC 139 ms
149,404 KB
testcase_18 AC 471 ms
212,748 KB
testcase_19 AC 889 ms
229,356 KB
testcase_20 AC 287 ms
139,704 KB
testcase_21 AC 152 ms
108,372 KB
testcase_22 AC 177 ms
131,600 KB
testcase_23 AC 99 ms
80,120 KB
testcase_24 AC 296 ms
224,924 KB
testcase_25 AC 840 ms
219,592 KB
testcase_26 AC 524 ms
219,496 KB
testcase_27 AC 2,205 ms
219,464 KB
testcase_28 AC 456 ms
219,484 KB
testcase_29 AC 1,862 ms
219,944 KB
testcase_30 AC 926 ms
219,340 KB
testcase_31 AC 652 ms
217,940 KB
testcase_32 AC 2,384 ms
219,804 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

from collections import deque

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

def ok(m):
    stack = deque()
    stack.append((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