結果

問題 No.972 選び方のスコア
ユーザー stngstng
提出日時 2022-08-18 18:49:57
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 86,808 KB
実行使用メモリ 102,200 KB
最終ジャッジ日時 2023-07-28 18:42:23
合計ジャッジ時間 8,077 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
100,408 KB
testcase_01 AC 161 ms
100,388 KB
testcase_02 AC 159 ms
100,352 KB
testcase_03 AC 118 ms
89,284 KB
testcase_04 AC 151 ms
98,924 KB
testcase_05 AC 147 ms
96,376 KB
testcase_06 AC 149 ms
98,920 KB
testcase_07 AC 142 ms
98,544 KB
testcase_08 AC 127 ms
99,812 KB
testcase_09 AC 125 ms
102,200 KB
testcase_10 AC 122 ms
100,008 KB
testcase_11 AC 127 ms
100,256 KB
testcase_12 AC 132 ms
100,652 KB
testcase_13 AC 133 ms
100,572 KB
testcase_14 AC 134 ms
100,648 KB
testcase_15 AC 149 ms
100,180 KB
testcase_16 AC 141 ms
100,712 KB
testcase_17 AC 138 ms
100,648 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 74 ms
71,284 KB
testcase_26 AC 72 ms
71,308 KB
testcase_27 AC 74 ms
71,088 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 77 ms
71,252 KB
testcase_31 AC 73 ms
71,216 KB
testcase_32 AC 76 ms
71,236 KB
testcase_33 AC 74 ms
71,132 KB
testcase_34 AC 73 ms
71,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = [int(i) for i in input().split()]

a.sort()

rui = [0]*(n+1)
for i in range(n):
    rui[i+1] = rui[i]+a[i]
#print(rui)
tmp = 0
now = a[0]
ans = 0
for i in range((n+1)//2):
    tmp = 0
    #bfr = a[i]
    aft = a[i+1]
    #chu = aft
    tmp += (rui[i+1]-rui[0])-aft*(i+1)
    #print(tmp,"t1")
    tmp += (rui[n]-rui[n-i-1])-aft*(i+1)
    #print(tmp,"t2")
    ans = max(ans,tmp)
    #print(tmp)

print(ans)
0