結果

問題 No.2495 Three Sets
ユーザー prin_kemkemprin_kemkem
提出日時 2023-10-06 22:45:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,160 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 97,988 KB
最終ジャッジ日時 2023-10-06 22:45:44
合計ジャッジ時間 8,107 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 171 ms
81,564 KB
testcase_01 AC 170 ms
81,528 KB
testcase_02 AC 192 ms
81,328 KB
testcase_03 AC 169 ms
81,356 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 168 ms
81,340 KB
testcase_07 AC 169 ms
81,396 KB
testcase_08 AC 172 ms
81,440 KB
testcase_09 AC 248 ms
83,876 KB
testcase_10 AC 282 ms
84,012 KB
testcase_11 AC 260 ms
83,604 KB
testcase_12 AC 316 ms
84,116 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque, Counter
import copy
from itertools import combinations, permutations, product, accumulate, groupby, chain
from heapq import heapify, heappop, heappush
import math
import bisect
from pprint import pprint
from random import randint
import sys
# sys.setrecursionlimit(700000)
input = lambda: sys.stdin.readline().rstrip('\n')
inf = float('inf')
mod1 = 10**9+7
mod2 = 998244353
def ceil_div(x, y): return -(-x//y)

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

class f(object):
    def __init__(self, x):
        sc = SC[x]
        self.val = sa*j + sb*x + sc*i
    def __eq__(self, other):
        if not isinstance(other, f):
            return NotImplemented
        return self.val == other.val
    def __lt__(self, other):
        if not isinstance(other, f):
            return NotImplemented
        return self.val < other.val
    def __ne__(self, other):
        return not self.__eq__(other)
    def __le__(self, other):
        return self.__lt__(other) or self.__eq__(other)
    def __gt__(self, other):
        return not self.__le__(other)
    def __ge__(self, other):
        return not self.__lt__(other)

def findMin(f, l, r):
    while r-l >= 3:
        c1 = l+(r-l)//3
        c2 = r-(r-l)//3
        if f(c1) < f(c2): r = c2
        else: l = c1
    return min(list(range(l, r+1)), key=lambda k: f(k))

def findMax(f, l, r):
    while r-l >= 3:
        c1 = l+(r-l)//3
        c2 = r-(r-l)//3
        if f(c1) > f(c2): r = c2
        else: l = c1
    return max(list(range(l, r+1)), key=lambda k: f(k))


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)

a, b, c = 0, 0, 0
while a < NA and A[a] >= 0:
    a += 1
while b < NB and B[b] >= 0:
    b += 1
while c < NC and C[c] >= 0:
    c += 1

SA = [0]+list(accumulate(A))
SB = [0]+list(accumulate(B))
SC = [0]+list(accumulate(C))

ans = 0
for i in range(a, NA+1):
    sa = SA[i]
    for j in range(b, NB+1):
        sb = SB[j]
        ans = max(ans, f(findMax(f, c, NC)).val)
print(ans)
0