結果

問題 No.972 選び方のスコア
ユーザー trineutrontrineutron
提出日時 2020-01-18 04:13:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 377 bytes
コンパイル時間 1,623 ms
コンパイル使用メモリ 170,096 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 15:37:47
合計ジャッジ時間 6,010 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
4,380 KB
testcase_01 AC 91 ms
4,376 KB
testcase_02 AC 87 ms
4,376 KB
testcase_03 AC 42 ms
4,376 KB
testcase_04 AC 83 ms
4,376 KB
testcase_05 AC 83 ms
4,376 KB
testcase_06 AC 83 ms
4,376 KB
testcase_07 AC 68 ms
4,376 KB
testcase_08 AC 73 ms
4,380 KB
testcase_09 AC 70 ms
4,376 KB
testcase_10 AC 72 ms
4,376 KB
testcase_11 AC 78 ms
4,376 KB
testcase_12 AC 77 ms
4,380 KB
testcase_13 AC 77 ms
4,380 KB
testcase_14 AC 78 ms
4,376 KB
testcase_15 AC 77 ms
4,376 KB
testcase_16 AC 79 ms
4,380 KB
testcase_17 AC 79 ms
4,376 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 2 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int64_t s = 0, ans = 0;
    for (int64_t i = 0; i < (n - 1) / 2; i++) {
        s += a[i] + a[n - 1 - i];
        ans = max(ans, s - 2 * (i + 1) * a[i + 1]);
    }
    cout << ans << endl;
}
0