結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー mkawa2mkawa2
提出日時 2019-12-16 22:34:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,234 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 186,752 KB
最終ジャッジ日時 2023-09-15 18:42:43
合計ジャッジ時間 19,897 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,824 KB
testcase_01 AC 16 ms
8,360 KB
testcase_02 AC 16 ms
8,256 KB
testcase_03 AC 16 ms
8,260 KB
testcase_04 AC 16 ms
8,324 KB
testcase_05 AC 16 ms
8,268 KB
testcase_06 AC 16 ms
8,324 KB
testcase_07 AC 20 ms
8,336 KB
testcase_08 AC 37 ms
8,880 KB
testcase_09 AC 22 ms
8,488 KB
testcase_10 AC 27 ms
8,584 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 AC 337 ms
20,560 KB
testcase_15 AC 1,737 ms
88,092 KB
testcase_16 TLE -
testcase_17 AC 456 ms
25,376 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

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