結果
| 問題 |
No.2495 Three Sets
|
| ユーザー |
mymelochan
|
| 提出日時 | 2023-10-07 01:15:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,498 ms / 3,000 ms |
| コード長 | 1,569 bytes |
| コンパイル時間 | 411 ms |
| コンパイル使用メモリ | 82,984 KB |
| 実行使用メモリ | 102,648 KB |
| 最終ジャッジ日時 | 2024-07-26 17:39:36 |
| 合計ジャッジ時間 | 26,264 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#############################################################
import sys
sys.setrecursionlimit(10**7)
from heapq import heappop,heappush
from collections import deque,defaultdict,Counter
from bisect import bisect_left, bisect_right
from itertools import product,combinations,permutations
ipt = sys.stdin.readline
def iin():
return int(ipt())
def lmin():
return list(map(int,ipt().split()))
MOD = 998244353
#############################################################
NA,NB,NC = lmin()
A = lmin()
B = lmin()
C = lmin()
M = 3000
cnt_A = [0]*(2*M+2)
cnt_B = [0]*(2*M+2)
cnt_C = [0]*(2*M+2)
for a in A:
cnt_A[a] += 1
for b in B:
cnt_B[b] += 1
for c in C:
cnt_C[c] += 1
cum_A = [0]*(2*M+2)
cum_cnt_A = [0]*(2*M+2)
for i in range(M,-M-1,-1):
cum_A[i] += cum_A[i+1]+cnt_A[i]*i
cum_cnt_A[i] += cum_cnt_A[i+1]+cnt_A[i]
cum_B = [0]*(2*M+2)
cum_cnt_B = [0]*(2*M+2)
for i in range(M,-M-1,-1):
cum_B[i] += cum_B[i+1]+cnt_B[i]*i
cum_cnt_B[i] += cum_cnt_B[i+1]+cnt_B[i]
cum_C = [0]*(2*M+2)
cum_cnt_C = [0]*(2*M+2)
for i in range(M,-M-1,-1):
cum_C[i] += cum_C[i+1]+cnt_C[i]*i
cum_cnt_C[i] += cum_cnt_C[i+1]+cnt_C[i]
ans = 0
SB = 0
cb = 0
for b in range(M+1,-M-1,-1):
for c in range(M+1,-M-1,-1):
if cum_cnt_B[b] > 0:
t = (-cum_C[c]+cum_cnt_B[b]-1)//cum_cnt_B[b]
t = max(-M,t)
t = min(M+1,t)
ans = max(ans, cum_cnt_B[b]*cum_A[t]+cum_cnt_A[t]*cum_C[c]+cum_B[b]*cum_cnt_C[c])
else:
ans = max(ans, max(0,NA*cum_C[c]+cum_B[b]*cum_cnt_C[c]))
print(ans)
mymelochan