結果

問題 No.972 選び方のスコア
ユーザー convexineqconvexineq
提出日時 2020-01-17 22:32:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 119,212 KB
最終ジャッジ日時 2023-09-08 04:50:26
合計ジャッジ時間 7,219 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 190 ms
106,876 KB
testcase_01 AC 190 ms
107,264 KB
testcase_02 AC 187 ms
108,740 KB
testcase_03 AC 135 ms
97,148 KB
testcase_04 AC 193 ms
109,184 KB
testcase_05 AC 188 ms
108,876 KB
testcase_06 AC 187 ms
109,196 KB
testcase_07 AC 166 ms
110,532 KB
testcase_08 AC 153 ms
107,172 KB
testcase_09 AC 151 ms
108,476 KB
testcase_10 AC 143 ms
118,300 KB
testcase_11 AC 142 ms
119,212 KB
testcase_12 AC 167 ms
118,568 KB
testcase_13 AC 164 ms
118,632 KB
testcase_14 AC 170 ms
118,672 KB
testcase_15 AC 173 ms
113,096 KB
testcase_16 AC 172 ms
114,912 KB
testcase_17 AC 171 ms
114,724 KB
testcase_18 AC 72 ms
71,292 KB
testcase_19 AC 192 ms
110,576 KB
testcase_20 AC 191 ms
110,784 KB
testcase_21 AC 192 ms
110,636 KB
testcase_22 AC 184 ms
110,700 KB
testcase_23 AC 191 ms
110,904 KB
testcase_24 AC 190 ms
110,592 KB
testcase_25 AC 78 ms
71,188 KB
testcase_26 AC 72 ms
71,216 KB
testcase_27 AC 70 ms
70,896 KB
testcase_28 AC 71 ms
71,088 KB
testcase_29 AC 73 ms
71,124 KB
testcase_30 AC 72 ms
71,072 KB
testcase_31 AC 72 ms
71,160 KB
testcase_32 AC 75 ms
71,128 KB
testcase_33 AC 80 ms
75,324 KB
testcase_34 AC 73 ms
71,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 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)
0