結果

問題 No.2495 Three Sets
ユーザー mkawa2mkawa2
提出日時 2023-10-06 22:35:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 243 ms / 3,000 ms
コード長 2,017 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 87,328 KB
実行使用メモリ 125,764 KB
最終ジャッジ日時 2023-10-06 22:35:21
合計ジャッジ時間 4,011 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,508 KB
testcase_01 AC 71 ms
71,200 KB
testcase_02 AC 76 ms
75,376 KB
testcase_03 AC 72 ms
71,680 KB
testcase_04 AC 69 ms
71,612 KB
testcase_05 AC 71 ms
71,664 KB
testcase_06 AC 73 ms
71,520 KB
testcase_07 AC 89 ms
71,480 KB
testcase_08 AC 74 ms
71,424 KB
testcase_09 AC 93 ms
77,140 KB
testcase_10 AC 95 ms
77,548 KB
testcase_11 AC 96 ms
77,472 KB
testcase_12 AC 102 ms
77,424 KB
testcase_13 AC 151 ms
87,168 KB
testcase_14 AC 201 ms
103,340 KB
testcase_15 AC 179 ms
90,184 KB
testcase_16 AC 242 ms
122,200 KB
testcase_17 AC 243 ms
122,416 KB
testcase_18 AC 72 ms
71,424 KB
testcase_19 AC 173 ms
123,048 KB
testcase_20 AC 170 ms
125,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 63)
# md = 10**9+7
md = 998244353

def cumsum(aa):
    cs = [0]
    for a in aa: cs.append(cs[-1]+a)
    return cs

def f(i, j, k):
    return sa[i]*j+sb[j]*k+sc[k]*i

na, nb, nc = LI()
aa = LI()
bb = LI()
cc = LI()
aa.sort(reverse=True)
bb.sort(reverse=True)
cc.sort(reverse=True)

sa = cumsum(aa)
sb = cumsum(bb)
sc = cumsum(cc)

def score(i,j):
    l,r=0,nc
    while 1:
        if l+1==r:
            return max(f(i,j,l),f(i,j,r))
        if l+2==r:
            m=(l+r)//2
            return max(f(i,j,l),f(i,j,m),f(i,j,r))
        m1=(l*2+r)//3
        m2=(l+r*2)//3
        if f(i,j,m1)>f(i,j,m2):
            r=m2
        else:
            l=m1

def search(i):
    l,r=0,nb
    while 1:
        if l+1==r:
            return max(score(i,l),score(i,r))
        if l+2==r:
            m=(l+r)//2
            return max(score(i,l),score(i,m),score(i,r))
        m1=(l*2+r)//3
        m2=(l+r*2)//3
        if score(i,m1)>score(i,m2):
            r=m2
        else:
            l=m1

l,r=0,na
ans=0
while 1:
    if l+1==r:
        ans=max(search(l),search(r))
        break
    if l+2==r:
        m=(l+r)//2
        ans=max(search(l),search(m),search(r))
        break
    m1=(l*2+r)//3
    m2=(l+r*2)//3
    if search(m1)>search(m2):
        r=m2
    else:
        l=m1

print(ans)
0