結果

問題 No.972 選び方のスコア
ユーザー titiatitia
提出日時 2020-01-17 22:49:05
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
TLE  
実行時間 -
コード長 539 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 31,456 KB
最終ジャッジ日時 2023-09-08 05:55:59
合計ジャッジ時間 61,382 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 TLE -
testcase_03 AC 1,221 ms
18,936 KB
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 AC 1,945 ms
24,580 KB
testcase_08 TLE -
testcase_09 TLE -
testcase_10 AC 1,987 ms
29,892 KB
testcase_11 TLE -
testcase_12 AC 1,957 ms
29,928 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 16 ms
8,064 KB
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 AC 16 ms
8,140 KB
testcase_26 AC 16 ms
8,220 KB
testcase_27 AC 16 ms
8,260 KB
testcase_28 AC 15 ms
8,140 KB
testcase_29 AC 17 ms
8,236 KB
testcase_30 AC 16 ms
8,260 KB
testcase_31 AC 16 ms
8,236 KB
testcase_32 AC 16 ms
8,188 KB
testcase_33 AC 17 ms
8,280 KB
testcase_34 AC 16 ms
8,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)

    
    
    
0