結果

問題 No.972 選び方のスコア
ユーザー titiatitia
提出日時 2020-01-17 22:10:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 317 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,608 KB
実行使用メモリ 41,076 KB
最終ジャッジ日時 2023-09-08 03:32:41
合計ジャッジ時間 8,252 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 268 ms
39,336 KB
testcase_01 AC 265 ms
41,076 KB
testcase_02 AC 248 ms
37,832 KB
testcase_03 AC 131 ms
23,388 KB
testcase_04 AC 268 ms
39,056 KB
testcase_05 AC 285 ms
39,260 KB
testcase_06 AC 277 ms
39,344 KB
testcase_07 AC 199 ms
31,468 KB
testcase_08 AC 187 ms
39,556 KB
testcase_09 AC 185 ms
38,220 KB
testcase_10 AC 181 ms
39,436 KB
testcase_11 AC 188 ms
39,124 KB
testcase_12 AC 186 ms
39,448 KB
testcase_13 AC 187 ms
39,280 KB
testcase_14 AC 186 ms
39,156 KB
testcase_15 AC 201 ms
38,960 KB
testcase_16 AC 200 ms
39,460 KB
testcase_17 AC 197 ms
39,212 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,068 KB
testcase_27 AC 15 ms
8,032 KB
testcase_28 AC 16 ms
8,156 KB
testcase_29 AC 15 ms
8,132 KB
testcase_30 AC 15 ms
8,112 KB
testcase_31 AC 16 ms
8,148 KB
testcase_32 AC 15 ms
8,044 KB
testcase_33 AC 16 ms
8,112 KB
testcase_34 AC 15 ms
8,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

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

if N<=2:
    print(0)
    sys.exit()

from itertools import accumulate

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

ANS=0

for i in range((N-1)//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