結果

問題 No.2495 Three Sets
ユーザー yupoohyupooh
提出日時 2023-10-06 21:40:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,031 bytes
コンパイル時間 409 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 120,580 KB
最終ジャッジ日時 2023-10-06 21:40:11
合計ジャッジ時間 4,654 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,516 KB
testcase_01 AC 74 ms
71,412 KB
testcase_02 AC 71 ms
71,140 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 69 ms
71,144 KB
testcase_07 WA -
testcase_08 AC 70 ms
71,224 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 71 ms
71,352 KB
testcase_19 AC 149 ms
120,580 KB
testcase_20 AC 119 ms
102,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
n=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
tota=0
totb=0
totc=0
numa=0
numb=0
numc=0
A=[]
for i in a:
  if i>=0:
    tota+=i
    numa+=1
  else:
    A.append(i)
B=[]
for i in b:
  if i>=0:
    totb+=i
    numb+=1
  else:
    B.append(i)
C=[]
for i in c:
  if i>=0:
    totc+=i
    numc+=1
  else:
    C.append(i)
A.sort()
B.sort()
C.sort()
ans=tota*numb+totb*numc+totc*numa
while True:
  flg=False
  if A:
    a=A[-1]
    tmp=(tota+a)*numb+totb*numc+totc*(numa+1)
    if ans<=tmp:
      ans=tmp
      tota+=a
      numa+=1
      flg=True
      A.pop()
  if B:
    b=B[-1]
    tmp=(tota)*(numb+1)+(totb+b)*numc+totc*(numa)
    if ans<=tmp:
      ans=tmp
      totb+=b
      numb+=1
      flg=True
      B.pop()  
  if C:
    c=C[-1]
    tmp=(tota)*numb+totb*(numc+1)+(totc+c)*(numa)
    if ans<=tmp:
      ans=tmp
      totc+=c
      numc+=1
      flg=True
      C.pop()
  if not flg:
    break
print(ans)
0