結果

問題 No.972 選び方のスコア
ユーザー maspy
提出日時 2020-03-18 13:02:30
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 470 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 29,664 KB
最終ジャッジ日時 2024-12-14 01:44:56
合計ジャッジ時間 8,260 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque

N, *A = map(int, read().split())
A = deque(sorted(A))

S = A.popleft()
med = S
best_score = 0
elem = 1
while len(A) > 1:
    L = A.popleft()
    R = A.pop()
    med = L
    S += L + R
    elem += 2
    score = S - med * elem
    if best_score < score:
        best_score = score

print(best_score)
0