結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー mkawa2mkawa2
提出日時 2019-12-16 22:49:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,195 ms / 2,500 ms
コード長 1,245 bytes
コンパイル時間 486 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 148,736 KB
最終ジャッジ日時 2023-09-15 18:47:00
合計ジャッジ時間 17,424 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,296 KB
testcase_01 AC 72 ms
71,328 KB
testcase_02 AC 72 ms
71,432 KB
testcase_03 AC 72 ms
71,292 KB
testcase_04 AC 75 ms
75,132 KB
testcase_05 AC 82 ms
75,840 KB
testcase_06 AC 82 ms
76,160 KB
testcase_07 AC 85 ms
75,964 KB
testcase_08 AC 102 ms
77,372 KB
testcase_09 AC 93 ms
76,628 KB
testcase_10 AC 93 ms
76,868 KB
testcase_11 AC 855 ms
127,560 KB
testcase_12 AC 839 ms
128,272 KB
testcase_13 AC 737 ms
122,280 KB
testcase_14 AC 193 ms
83,520 KB
testcase_15 AC 564 ms
112,172 KB
testcase_16 AC 889 ms
141,944 KB
testcase_17 AC 218 ms
85,212 KB
testcase_18 AC 1,185 ms
144,780 KB
testcase_19 AC 560 ms
128,368 KB
testcase_20 AC 195 ms
87,648 KB
testcase_21 AC 117 ms
81,472 KB
testcase_22 AC 140 ms
86,508 KB
testcase_23 AC 81 ms
76,140 KB
testcase_24 AC 636 ms
114,036 KB
testcase_25 AC 1,130 ms
147,976 KB
testcase_26 AC 1,179 ms
148,060 KB
testcase_27 AC 1,074 ms
148,352 KB
testcase_28 AC 1,195 ms
148,324 KB
testcase_29 AC 810 ms
148,692 KB
testcase_30 AC 439 ms
147,912 KB
testcase_31 AC 340 ms
134,264 KB
testcase_32 AC 1,045 ms
148,736 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回のんだとき
    dpi1=dp[0]
    for i in range(n):
        dpi=dpi1
        dpi1=dp[i+1]
        for j in range(n):
            pre = dpi[j]
            if pre < 1: continue
            # iを進める場合
            di = bisect_right(dd, aa[i + 1] + bb[j], 0, pre) - 1
            if di > dpi1[j]: dpi1[j] = di
            # jを進める場合
            di = bisect_right(dd, aa[i] + bb[j + 1], 0, pre) - 1
            if di > dpi[j + 1]: dpi[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