結果

問題 No.972 選び方のスコア
ユーザー stngstng
提出日時 2022-08-18 18:45:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 420 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 98,816 KB
最終ジャッジ日時 2024-04-16 02:37:27
合計ジャッジ時間 5,953 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
96,640 KB
testcase_01 AC 134 ms
98,688 KB
testcase_02 AC 131 ms
98,816 KB
testcase_03 AC 98 ms
85,120 KB
testcase_04 AC 136 ms
98,432 KB
testcase_05 AC 138 ms
98,304 KB
testcase_06 AC 138 ms
98,816 KB
testcase_07 AC 121 ms
97,024 KB
testcase_08 AC 97 ms
97,280 KB
testcase_09 AC 98 ms
96,768 KB
testcase_10 AC 95 ms
97,280 KB
testcase_11 AC 96 ms
97,792 KB
testcase_12 AC 102 ms
97,536 KB
testcase_13 AC 109 ms
97,408 KB
testcase_14 AC 102 ms
97,664 KB
testcase_15 AC 115 ms
98,688 KB
testcase_16 AC 108 ms
96,512 KB
testcase_17 AC 107 ms
96,512 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 40 ms
52,096 KB
testcase_26 AC 40 ms
52,352 KB
testcase_27 AC 40 ms
51,840 KB
testcase_28 AC 40 ms
51,968 KB
testcase_29 AC 40 ms
52,224 KB
testcase_30 AC 41 ms
51,968 KB
testcase_31 AC 41 ms
51,968 KB
testcase_32 AC 42 ms
51,968 KB
testcase_33 AC 41 ms
52,224 KB
testcase_34 AC 41 ms
51,712 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):
    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