結果
| 問題 |
No.2495 Three Sets
|
| コンテスト | |
| ユーザー |
yupooh
|
| 提出日時 | 2023-10-06 21:40:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,031 bytes |
| コンパイル時間 | 162 ms |
| コンパイル使用メモリ | 82,512 KB |
| 実行使用メモリ | 110,480 KB |
| 最終ジャッジ日時 | 2024-07-26 15:52:57 |
| 合計ジャッジ時間 | 2,903 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 13 |
ソースコード
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)
yupooh