結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー tamatotamato
提出日時 2019-12-12 15:43:17
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,226 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 350,476 KB
最終ジャッジ日時 2023-09-07 07:53:55
合計ジャッジ時間 8,429 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
75,848 KB
testcase_01 AC 94 ms
71,336 KB
testcase_02 AC 96 ms
71,672 KB
testcase_03 AC 93 ms
71,860 KB
testcase_04 AC 94 ms
71,816 KB
testcase_05 AC 97 ms
71,864 KB
testcase_06 AC 94 ms
71,492 KB
testcase_07 AC 96 ms
72,244 KB
testcase_08 AC 110 ms
77,504 KB
testcase_09 AC 108 ms
77,064 KB
testcase_10 AC 107 ms
77,500 KB
testcase_11 AC 359 ms
200,884 KB
testcase_12 AC 118 ms
77,932 KB
testcase_13 AC 268 ms
147,756 KB
testcase_14 AC 116 ms
77,844 KB
testcase_15 AC 1,421 ms
306,612 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    D = list(map(int, input().split()))

    D.sort()
    ok = 0
    ng = N+1
    mid = (ok + ng) // 2
    while ng - ok > 1:
        seen = defaultdict(int)
        st = [(0, 0)]
        seen[0] = 1
        flg = 0
        while st:
            i, j = st.pop()
            if i+1 <= N:
                if seen[(i+1) * (N+1) + j] == 0:
                    seen[(i+1) * (N+1) + j] = 1
                    if A[i+1] + B[j] >= D[mid-(i+j+1)]:
                        if i+j+1 == mid:
                            flg = 1
                            break
                        st.append((i+1, j))
            if j+1 <= N:
                if seen[i * (N+1) + j+1] == 0:
                    seen[i * (N+1) + j+1] = 1
                    if A[i] + B[j+1] >= D[mid-(i+j+1)]:
                        if i+j+1 == mid:
                            flg = 1
                            break
                        st.append((i, j+1))
        if flg:
            ok = mid
        else:
            ng = mid
        mid = (ok+ng)//2

    print(ok)


if __name__ == '__main__':
    main()
0