結果

問題 No.1906 Twinkle Town
ユーザー Kude
提出日時 2022-04-15 22:27:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 277 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 82,524 KB
実行使用メモリ 117,928 KB
最終ジャッジ日時 2024-12-25 01:18:02
合計ジャッジ時間 9,827 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other WA * 47
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    n = int(input())
    a = sorted(map(int, input().split()))
    d = [y - x for x, y in zip(a, a[1:])]
    d.sort(reverse=True)
    if n % 2:
        ans = a[0] + sum(d[::2])
    else:
        ans = a[-1] - (a[0] + sum(d[:n-2:2]))
    print(ans)
0