結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー 👑 tamatotamato
提出日時 2019-12-12 15:33:42
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 2,220 ms / 2,500 ms
コード長 1,199 bytes
コンパイル時間 417 ms
コンパイル使用メモリ 86,552 KB
実行使用メモリ 467,384 KB
最終ジャッジ日時 2023-09-07 07:42:45
合計ジャッジ時間 20,938 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,252 KB
testcase_01 AC 77 ms
71,416 KB
testcase_02 AC 77 ms
70,948 KB
testcase_03 AC 76 ms
71,236 KB
testcase_04 AC 78 ms
74,816 KB
testcase_05 AC 79 ms
75,036 KB
testcase_06 AC 80 ms
74,944 KB
testcase_07 AC 81 ms
75,204 KB
testcase_08 AC 96 ms
76,396 KB
testcase_09 AC 86 ms
76,096 KB
testcase_10 AC 92 ms
76,416 KB
testcase_11 AC 695 ms
325,768 KB
testcase_12 AC 592 ms
312,840 KB
testcase_13 AC 598 ms
339,620 KB
testcase_14 AC 157 ms
114,060 KB
testcase_15 AC 808 ms
311,896 KB
testcase_16 AC 1,564 ms
402,940 KB
testcase_17 AC 181 ms
141,256 KB
testcase_18 AC 815 ms
441,760 KB
testcase_19 AC 1,063 ms
329,488 KB
testcase_20 AC 286 ms
170,484 KB
testcase_21 AC 139 ms
93,972 KB
testcase_22 AC 206 ms
142,668 KB
testcase_23 AC 90 ms
75,912 KB
testcase_24 AC 489 ms
315,140 KB
testcase_25 AC 1,001 ms
424,916 KB
testcase_26 AC 897 ms
466,520 KB
testcase_27 AC 2,220 ms
430,992 KB
testcase_28 AC 893 ms
467,384 KB
testcase_29 AC 1,415 ms
373,556 KB
testcase_30 AC 865 ms
408,104 KB
testcase_31 AC 767 ms
411,252 KB
testcase_32 AC 1,832 ms
392,552 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:
        d = D[:mid]
        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[-(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[-(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