結果

問題 No.972 選び方のスコア
ユーザー titiatitia
提出日時 2020-01-17 21:57:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 487 bytes
コンパイル時間 997 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 52,060 KB
最終ジャッジ日時 2023-09-08 02:46:05
合計ジャッジ時間 11,448 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 420 ms
51,920 KB
testcase_01 AC 385 ms
50,624 KB
testcase_02 AC 381 ms
49,960 KB
testcase_03 AC 183 ms
29,012 KB
testcase_04 AC 400 ms
51,736 KB
testcase_05 AC 392 ms
51,612 KB
testcase_06 AC 399 ms
51,704 KB
testcase_07 AC 273 ms
40,028 KB
testcase_08 AC 270 ms
50,548 KB
testcase_09 AC 257 ms
48,876 KB
testcase_10 AC 263 ms
50,448 KB
testcase_11 AC 264 ms
50,208 KB
testcase_12 AC 280 ms
51,800 KB
testcase_13 AC 274 ms
51,800 KB
testcase_14 AC 277 ms
51,792 KB
testcase_15 AC 298 ms
51,504 KB
testcase_16 AC 294 ms
51,860 KB
testcase_17 AC 292 ms
52,060 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,156 KB
testcase_26 AC 15 ms
8,200 KB
testcase_27 AC 16 ms
8,052 KB
testcase_28 AC 15 ms
8,084 KB
testcase_29 AC 15 ms
8,032 KB
testcase_30 AC 15 ms
8,248 KB
testcase_31 AC 14 ms
8,184 KB
testcase_32 AC 15 ms
8,112 KB
testcase_33 AC 15 ms
8,132 KB
testcase_34 AC 16 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//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