結果

問題 No.972 選び方のスコア
ユーザー titiatitia
提出日時 2020-01-17 21:54:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 437 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 51,856 KB
最終ジャッジ日時 2023-09-08 02:40:14
合計ジャッジ時間 11,357 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 402 ms
50,212 KB
testcase_01 AC 412 ms
51,776 KB
testcase_02 AC 378 ms
48,408 KB
testcase_03 AC 190 ms
28,852 KB
testcase_04 AC 400 ms
50,064 KB
testcase_05 AC 395 ms
51,476 KB
testcase_06 AC 405 ms
51,744 KB
testcase_07 AC 291 ms
39,972 KB
testcase_08 AC 275 ms
50,228 KB
testcase_09 AC 270 ms
48,940 KB
testcase_10 AC 274 ms
50,360 KB
testcase_11 AC 274 ms
50,252 KB
testcase_12 AC 281 ms
51,844 KB
testcase_13 AC 281 ms
51,856 KB
testcase_14 AC 280 ms
51,804 KB
testcase_15 AC 296 ms
49,924 KB
testcase_16 AC 293 ms
50,316 KB
testcase_17 AC 288 ms
50,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 16 ms
8,112 KB
testcase_26 AC 16 ms
8,188 KB
testcase_27 AC 16 ms
8,116 KB
testcase_28 AC 16 ms
8,136 KB
testcase_29 AC 16 ms
8,160 KB
testcase_30 AC 16 ms
8,228 KB
testcase_31 AC 16 ms
8,092 KB
testcase_32 AC 15 ms
8,232 KB
testcase_33 AC 16 ms
8,248 KB
testcase_34 AC 15 ms
8,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=sorted(map(int,input().split()))

from itertools import accumulate

S=list(accumulate(A))
S2=list(accumulate(A[::-1]))

ANS=0

for i in range(N//2):
    #print(S[i]+S2[i]-A[i+1]*(2*(i+1)))
    ANS=max(ANS,S[i]+S2[i]-A[i+1]*(2*(i+1)))

A=A[::-1]

S=list(accumulate(A))
S2=list(accumulate(A[::-1]))


for i in range(N//2):
    #print(S[i]+S2[i]-A[i+1]*(2*(i+1)))
    ANS=max(ANS,S[i]+S2[i]-A[i+1]*(2*(i+1)))



print(ANS)
0