結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー tamatotamato
提出日時 2019-12-12 15:36:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,363 ms / 2,500 ms
コード長 1,185 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 467,208 KB
最終ジャッジ日時 2023-09-07 07:46:37
合計ジャッジ時間 22,194 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,008 KB
testcase_01 AC 77 ms
71,028 KB
testcase_02 AC 75 ms
70,892 KB
testcase_03 AC 75 ms
71,208 KB
testcase_04 AC 77 ms
74,952 KB
testcase_05 AC 78 ms
75,024 KB
testcase_06 AC 80 ms
74,932 KB
testcase_07 AC 81 ms
75,076 KB
testcase_08 AC 94 ms
76,424 KB
testcase_09 AC 84 ms
76,132 KB
testcase_10 AC 89 ms
76,268 KB
testcase_11 AC 658 ms
325,184 KB
testcase_12 AC 602 ms
312,592 KB
testcase_13 AC 617 ms
339,716 KB
testcase_14 AC 157 ms
113,948 KB
testcase_15 AC 833 ms
311,936 KB
testcase_16 AC 1,578 ms
402,644 KB
testcase_17 AC 247 ms
141,040 KB
testcase_18 AC 860 ms
440,860 KB
testcase_19 AC 1,188 ms
329,032 KB
testcase_20 AC 288 ms
170,416 KB
testcase_21 AC 136 ms
93,812 KB
testcase_22 AC 204 ms
142,424 KB
testcase_23 AC 86 ms
75,800 KB
testcase_24 AC 495 ms
314,628 KB
testcase_25 AC 996 ms
425,096 KB
testcase_26 AC 895 ms
466,728 KB
testcase_27 AC 2,363 ms
430,212 KB
testcase_28 AC 893 ms
467,208 KB
testcase_29 AC 1,451 ms
373,084 KB
testcase_30 AC 865 ms
407,988 KB
testcase_31 AC 784 ms
411,044 KB
testcase_32 AC 1,859 ms
392,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 = [[0 for _ in range(N+1)] for _ in range(N+1)]
        st = [(0, 0)]
        seen[0][0] = 1
        flg = 0
        while st:
            i, j = st.pop()
            if i+1 <= N:
                if seen[i+1][j] == 0:
                    seen[i + 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][j+1] == 0:
                    seen[i][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