結果
| 問題 |
No.972 選び方のスコア
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2020-01-17 22:49:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 196 ms / 2,000 ms |
| コード長 | 539 bytes |
| コンパイル時間 | 340 ms |
| コンパイル使用メモリ | 82,148 KB |
| 実行使用メモリ | 116,220 KB |
| 最終ジャッジ日時 | 2024-06-25 23:07:15 |
| 合計ジャッジ時間 | 6,654 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
import sys
N=int(input())
A=sorted(map(int,input().split()))
from itertools import accumulate
S=[0]+list(accumulate(A))
if N<=2:
print(0)
sys.exit()
ANS=0
for i in range(1,N-1):
OK=0
NG=i+1
while NG-OK>1:
mid=(OK+NG)//2
if mid>=1 and A[-mid]-A[i]>A[i]-A[i-mid]:
OK=mid
else:
NG=mid
if OK==0:
continue
#print(i,OK,S[-1]-S[-OK-1]+S[i+1]-S[i-OK]-A[i]*(2*OK+1))
ANS=max(ANS,S[-1]-S[-OK-1]+S[i+1]-S[i-OK]-A[i]*(2*OK+1))
print(ANS)
titia