結果

問題 No.972 選び方のスコア
ユーザー NagisaNagisa
提出日時 2020-01-17 22:51:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 342 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 10,848 KB
実行使用メモリ 40,856 KB
最終ジャッジ日時 2023-09-08 06:02:37
合計ジャッジ時間 13,377 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 504 ms
39,220 KB
testcase_01 AC 498 ms
39,720 KB
testcase_02 AC 480 ms
37,948 KB
testcase_03 AC 249 ms
23,516 KB
testcase_04 AC 519 ms
39,272 KB
testcase_05 AC 512 ms
39,172 KB
testcase_06 AC 512 ms
39,284 KB
testcase_07 AC 388 ms
31,468 KB
testcase_08 AC 361 ms
39,564 KB
testcase_09 AC 358 ms
38,132 KB
testcase_10 AC 359 ms
39,584 KB
testcase_11 AC 371 ms
39,168 KB
testcase_12 AC 369 ms
39,252 KB
testcase_13 AC 373 ms
39,396 KB
testcase_14 AC 371 ms
39,180 KB
testcase_15 AC 383 ms
38,968 KB
testcase_16 AC 380 ms
39,156 KB
testcase_17 AC 381 ms
39,204 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
7,856 KB
testcase_26 AC 16 ms
7,928 KB
testcase_27 AC 16 ms
7,804 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 16 ms
7,928 KB
testcase_31 AC 16 ms
7,776 KB
testcase_32 AC 16 ms
7,772 KB
testcase_33 AC 16 ms
7,824 KB
testcase_34 AC 17 ms
7,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = sorted(list(map(int,input().split())))
S = [0 for k in range(N)]
S[0] = A[0]
for k in range(1,N):
    S[k] = S[k-1] + A[k]
B = A[::-1]
T = [0 for k in range(N)]
T[0] = B[0]
for k in range(1,N):
    T[k] = T[k-1] + B[k]
ans = -float("inf")
for k in range(1,N-1):
    ans = max(ans,-k*A[k]+S[k-1]+T[k-1]-k*A[k])
print(ans)
0