結果
問題 | No.2495 Three Sets |
ユーザー |
![]() |
提出日時 | 2023-10-06 22:35:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 210 ms / 3,000 ms |
コード長 | 2,017 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 82,856 KB |
実行使用メモリ | 115,004 KB |
最終ジャッジ日時 | 2024-07-26 16:40:25 |
合計ジャッジ時間 | 3,004 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
import sys# sys.setrecursionlimit(200005)# sys.set_int_max_str_digits(200005)int1 = lambda x: int(x)-1pDB = 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+7md = 998244353def cumsum(aa):cs = [0]for a in aa: cs.append(cs[-1]+a)return csdef f(i, j, k):return sa[i]*j+sb[j]*k+sc[k]*ina, 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,ncwhile 1:if l+1==r:return max(f(i,j,l),f(i,j,r))if l+2==r:m=(l+r)//2return max(f(i,j,l),f(i,j,m),f(i,j,r))m1=(l*2+r)//3m2=(l+r*2)//3if f(i,j,m1)>f(i,j,m2):r=m2else:l=m1def search(i):l,r=0,nbwhile 1:if l+1==r:return max(score(i,l),score(i,r))if l+2==r:m=(l+r)//2return max(score(i,l),score(i,m),score(i,r))m1=(l*2+r)//3m2=(l+r*2)//3if score(i,m1)>score(i,m2):r=m2else:l=m1l,r=0,naans=0while 1:if l+1==r:ans=max(search(l),search(r))breakif l+2==r:m=(l+r)//2ans=max(search(l),search(m),search(r))breakm1=(l*2+r)//3m2=(l+r*2)//3if search(m1)>search(m2):r=m2else:l=m1print(ans)