結果

問題 No.972 選び方のスコア
ユーザー titiatitia
提出日時 2020-01-17 22:06:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 313 bytes
コンパイル時間 394 ms
コンパイル使用メモリ 10,584 KB
実行使用メモリ 40,948 KB
最終ジャッジ日時 2023-09-08 03:11:37
合計ジャッジ時間 7,900 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 259 ms
39,244 KB
testcase_01 AC 258 ms
39,616 KB
testcase_02 AC 238 ms
37,868 KB
testcase_03 AC 127 ms
23,596 KB
testcase_04 AC 268 ms
39,176 KB
testcase_05 AC 265 ms
39,108 KB
testcase_06 AC 259 ms
39,220 KB
testcase_07 AC 196 ms
31,552 KB
testcase_08 AC 177 ms
39,388 KB
testcase_09 AC 178 ms
38,144 KB
testcase_10 AC 174 ms
39,536 KB
testcase_11 AC 180 ms
39,208 KB
testcase_12 AC 182 ms
39,332 KB
testcase_13 AC 181 ms
39,268 KB
testcase_14 AC 183 ms
39,184 KB
testcase_15 AC 198 ms
39,140 KB
testcase_16 AC 194 ms
39,196 KB
testcase_17 AC 194 ms
39,264 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,148 KB
testcase_26 AC 15 ms
8,236 KB
testcase_27 AC 15 ms
8,056 KB
testcase_28 AC 15 ms
8,024 KB
testcase_29 AC 15 ms
8,060 KB
testcase_30 AC 15 ms
8,120 KB
testcase_31 AC 15 ms
8,128 KB
testcase_32 AC 15 ms
8,200 KB
testcase_33 AC 15 ms
8,168 KB
testcase_34 AC 15 ms
8,068 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)))

print(ANS)
0