結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー 👑 tamatotamato
提出日時 2019-12-12 16:45:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,788 ms / 2,500 ms
コード長 1,152 bytes
コンパイル時間 1,137 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 289,116 KB
最終ジャッジ日時 2023-09-07 09:21:09
合計ジャッジ時間 23,132 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,376 KB
testcase_01 AC 95 ms
71,432 KB
testcase_02 AC 92 ms
71,296 KB
testcase_03 AC 92 ms
71,616 KB
testcase_04 AC 92 ms
71,372 KB
testcase_05 AC 104 ms
76,844 KB
testcase_06 AC 99 ms
76,608 KB
testcase_07 AC 107 ms
77,012 KB
testcase_08 AC 115 ms
77,632 KB
testcase_09 AC 113 ms
77,084 KB
testcase_10 AC 106 ms
77,404 KB
testcase_11 AC 654 ms
206,168 KB
testcase_12 AC 1,087 ms
289,116 KB
testcase_13 AC 769 ms
204,476 KB
testcase_14 AC 181 ms
84,668 KB
testcase_15 AC 768 ms
205,016 KB
testcase_16 AC 1,477 ms
282,276 KB
testcase_17 AC 262 ms
95,420 KB
testcase_18 AC 1,788 ms
284,056 KB
testcase_19 AC 697 ms
210,072 KB
testcase_20 AC 207 ms
91,564 KB
testcase_21 AC 132 ms
81,576 KB
testcase_22 AC 147 ms
86,680 KB
testcase_23 AC 99 ms
72,504 KB
testcase_24 AC 894 ms
250,584 KB
testcase_25 AC 1,001 ms
280,496 KB
testcase_26 AC 1,289 ms
284,560 KB
testcase_27 AC 1,429 ms
283,384 KB
testcase_28 AC 1,770 ms
288,164 KB
testcase_29 AC 927 ms
283,436 KB
testcase_30 AC 307 ms
156,116 KB
testcase_31 AC 129 ms
147,228 KB
testcase_32 AC 1,356 ms
287,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque


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
    seen = [0] * ((N+1)**2)
    while ng - ok > 1:
        st = deque()
        st.append((0, 0))
        seen[0] = mid
        flg = 0
        while st:
            i, j = st.popleft()
            k = i+j+1
            if seen[(i+1) * (N+1) + j] != mid:
                seen[(i+1) * (N+1) + j] = mid
                if A[i+1] + B[j] >= D[mid-k]:
                    if k == mid:
                        flg = 1
                        break
                    st.append((i+1, j))
            if seen[i * (N+1) + j+1] != mid:
                seen[i * (N+1) + j+1] = mid
                if A[i] + B[j+1] >= D[mid-k]:
                    if k == 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