結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー mkawa2mkawa2
提出日時 2019-12-16 22:34:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,640 ms / 2,500 ms
コード長 1,234 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 86,744 KB
実行使用メモリ 148,776 KB
最終ジャッジ日時 2023-09-15 18:44:46
合計ジャッジ時間 21,755 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,344 KB
testcase_01 AC 75 ms
71,372 KB
testcase_02 AC 75 ms
71,364 KB
testcase_03 AC 74 ms
71,156 KB
testcase_04 AC 77 ms
75,384 KB
testcase_05 AC 83 ms
76,216 KB
testcase_06 AC 82 ms
75,644 KB
testcase_07 AC 90 ms
76,880 KB
testcase_08 AC 103 ms
77,280 KB
testcase_09 AC 92 ms
76,508 KB
testcase_10 AC 93 ms
76,948 KB
testcase_11 AC 1,137 ms
127,664 KB
testcase_12 AC 1,184 ms
128,340 KB
testcase_13 AC 1,057 ms
122,368 KB
testcase_14 AC 199 ms
83,560 KB
testcase_15 AC 712 ms
112,292 KB
testcase_16 AC 1,227 ms
142,304 KB
testcase_17 AC 232 ms
85,160 KB
testcase_18 AC 1,540 ms
144,620 KB
testcase_19 AC 711 ms
128,280 KB
testcase_20 AC 216 ms
87,856 KB
testcase_21 AC 129 ms
81,760 KB
testcase_22 AC 163 ms
86,916 KB
testcase_23 AC 83 ms
76,052 KB
testcase_24 AC 845 ms
114,184 KB
testcase_25 AC 1,640 ms
148,312 KB
testcase_26 AC 1,631 ms
147,912 KB
testcase_27 AC 1,333 ms
148,776 KB
testcase_28 AC 1,549 ms
148,012 KB
testcase_29 AC 1,047 ms
148,416 KB
testcase_30 AC 580 ms
148,552 KB
testcase_31 AC 393 ms
134,372 KB
testcase_32 AC 1,437 ms
148,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_right
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n = int(input())
    aa = LI()
    bb = LI()
    dd = LI()
    dd.sort()
    # dp[i][j]kenがi回、kooがj回飲んだとき、何番目の問題まで進んだかの最大値
    dp = [[-1] * (n + 1) for _ in range(n + 1)]
    dp[0][0] = n
    # 2人合わせてs回のんだとき
    for s in range(n):
        for i in range(s + 1):
            j = s - i
            pre = dp[i][j]
            if pre < 1: continue
            # iを進める場合
            di = bisect_right(dd, aa[i + 1] + bb[j], 0, pre) - 1
            if di > dp[i + 1][j]: dp[i + 1][j] = di
            # jを進める場合
            di = bisect_right(dd, aa[i] + bb[j + 1], 0, pre) - 1
            if di > dp[i][j + 1]: dp[i][j + 1] = di
    #p2D(dp)
    for s in range(n,-1,-1):
        for i in range(n+1):
            j=s-i
            if dp[i][j]>-1:
                print(s)
                exit()
main()
0