結果
| 問題 |
No.972 選び方のスコア
|
| コンテスト | |
| ユーザー |
convexineq
|
| 提出日時 | 2020-01-17 22:32:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 173 ms / 2,000 ms |
| コード長 | 640 bytes |
| コンパイル時間 | 366 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 119,808 KB |
| 最終ジャッジ日時 | 2024-06-25 22:05:06 |
| 合計ジャッジ時間 | 6,000 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read
#n,m,*d= [int(i) for i in read().split()]
#a,t,k = [int(i) for i in readline().split()]
n,*a = [int(i) for i in read().split()]
a.sort()
from itertools import accumulate
acc = list(accumulate([0]+a))
ans = 0
for i in range(n):
ok = 0
ng = min(i,n-i-1)+1
while ng - ok > 1:
mid = (ok+ng)//2
if a[i-mid] + a[n-mid] > 2*a[i]: ok = mid
else: ng = mid
res = acc[n]-acc[n-ok]+acc[i+1]-acc[i-ok]-a[i]*(2*ok+1)
#print(res,i,ok)
if ans < res: ans = res
print(ans)
convexineq