結果

問題 No.2495 Three Sets
ユーザー mymelochanmymelochan
提出日時 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
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 944 ms
77,888 KB
testcase_01 AC 961 ms
78,064 KB
testcase_02 AC 1,357 ms
77,980 KB
testcase_03 AC 940 ms
78,096 KB
testcase_04 AC 906 ms
77,336 KB
testcase_05 AC 930 ms
78,092 KB
testcase_06 AC 1,032 ms
77,948 KB
testcase_07 AC 1,336 ms
78,016 KB
testcase_08 AC 1,393 ms
78,060 KB
testcase_09 AC 999 ms
78,448 KB
testcase_10 AC 971 ms
78,268 KB
testcase_11 AC 1,406 ms
78,704 KB
testcase_12 AC 1,498 ms
78,256 KB
testcase_13 AC 1,397 ms
87,332 KB
testcase_14 AC 1,459 ms
94,640 KB
testcase_15 AC 1,397 ms
90,692 KB
testcase_16 AC 1,448 ms
101,884 KB
testcase_17 AC 1,447 ms
102,180 KB
testcase_18 AC 504 ms
77,348 KB
testcase_19 AC 516 ms
102,648 KB
testcase_20 AC 1,247 ms
102,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#############################################################

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)
0