結果
問題 | No.2495 Three Sets |
ユーザー | mymelochan |
提出日時 | 2023-10-07 01:15:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,649 ms / 3,000 ms |
コード長 | 1,569 bytes |
コンパイル時間 | 325 ms |
コンパイル使用メモリ | 87,040 KB |
実行使用メモリ | 117,804 KB |
最終ジャッジ日時 | 2023-10-07 01:16:07 |
合計ジャッジ時間 | 29,717 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,029 ms
78,860 KB |
testcase_01 | AC | 1,068 ms
79,088 KB |
testcase_02 | AC | 1,507 ms
79,020 KB |
testcase_03 | AC | 1,079 ms
79,136 KB |
testcase_04 | AC | 1,041 ms
78,592 KB |
testcase_05 | AC | 1,061 ms
78,952 KB |
testcase_06 | AC | 1,186 ms
79,212 KB |
testcase_07 | AC | 1,477 ms
79,060 KB |
testcase_08 | AC | 1,574 ms
79,048 KB |
testcase_09 | AC | 1,134 ms
79,388 KB |
testcase_10 | AC | 1,076 ms
79,316 KB |
testcase_11 | AC | 1,586 ms
79,188 KB |
testcase_12 | AC | 1,649 ms
79,588 KB |
testcase_13 | AC | 1,555 ms
89,444 KB |
testcase_14 | AC | 1,585 ms
103,556 KB |
testcase_15 | AC | 1,550 ms
92,788 KB |
testcase_16 | AC | 1,621 ms
117,684 KB |
testcase_17 | AC | 1,625 ms
117,804 KB |
testcase_18 | AC | 584 ms
78,716 KB |
testcase_19 | AC | 607 ms
115,012 KB |
testcase_20 | AC | 1,410 ms
117,596 KB |
ソースコード
############################################################# 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)