結果
問題 | No.2495 Three Sets |
ユーザー |
![]() |
提出日時 | 2023-10-06 23:31:18 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 241 ms / 3,000 ms |
コード長 | 1,326 bytes |
コンパイル時間 | 229 ms |
コンパイル使用メモリ | 82,224 KB |
実行使用メモリ | 122,292 KB |
最終ジャッジ日時 | 2024-07-26 17:09:44 |
合計ジャッジ時間 | 4,074 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
from collections import defaultdict, deque, Counterimport copyfrom itertools import combinations, permutations, product, accumulate, groupby, chainfrom heapq import heapify, heappop, heappushimport mathimport bisectfrom pprint import pprintfrom random import randintimport sys# sys.setrecursionlimit(700000)input = lambda: sys.stdin.readline().rstrip('\n')inf = float('inf')mod1 = 10**9+7mod2 = 998244353def ceil_div(x, y): return -(-x//y)#################################################def f(k):sa = SA[i]sb = SB[j]sc = SC[k]return sa*j + sb*k + sc*idef f(i):def g(j):def h(k):sa = SA[i]sb = SB[j]sc = SC[k]return sa*j + sb*k + sc*ireturn findMax(h, 0, NC)return findMax(g, 0, NB)def findMax(f, l, r):while r-l >= 3:c1 = l+(r-l)//3c2 = r-(r-l)//3if f(c1) > f(c2): r = c2else: l = c1return max(f(x) for x in range(l, r+1))NA, NB, NC = map(int, input().split())A = list(map(int, input().split()))B = list(map(int, input().split()))C = list(map(int, input().split()))A.sort(reverse=True)B.sort(reverse=True)C.sort(reverse=True)SA = [0]+list(accumulate(A))SB = [0]+list(accumulate(B))SC = [0]+list(accumulate(C))ans = findMax(f, 0, NA)print(ans)