結果
| 問題 |
No.972 選び方のスコア
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2020-01-17 22:49:05 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 539 bytes |
| コンパイル時間 | 79 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 32,952 KB |
| 最終ジャッジ日時 | 2024-06-25 23:09:43 |
| 合計ジャッジ時間 | 38,199 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 TLE * 18 |
ソースコード
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