結果

問題 No.972 選び方のスコア
ユーザー finefine
提出日時 2020-01-17 21:46:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 2,128 ms
コンパイル使用メモリ 170,716 KB
実行使用メモリ 4,756 KB
最終ジャッジ日時 2023-09-08 02:15:40
合計ジャッジ時間 3,965 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
4,636 KB
testcase_01 AC 41 ms
4,624 KB
testcase_02 AC 40 ms
4,592 KB
testcase_03 AC 21 ms
4,376 KB
testcase_04 AC 40 ms
4,580 KB
testcase_05 AC 39 ms
4,640 KB
testcase_06 AC 40 ms
4,756 KB
testcase_07 AC 31 ms
4,384 KB
testcase_08 AC 28 ms
4,576 KB
testcase_09 AC 27 ms
4,544 KB
testcase_10 AC 26 ms
4,540 KB
testcase_11 AC 28 ms
4,536 KB
testcase_12 AC 28 ms
4,636 KB
testcase_13 AC 28 ms
4,592 KB
testcase_14 AC 28 ms
4,644 KB
testcase_15 AC 29 ms
4,576 KB
testcase_16 AC 29 ms
4,536 KB
testcase_17 AC 29 ms
4,544 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,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    ll ans = 0, sumR = 0, sumL = 0;
    for (int i = 1; i < n; ++i) {
        if (i * 2 + 1 > n) break;
        sumR += a[n - i];
        sumL += a[i - 1];
        ans = max(ans, sumR + sumL - a[i] * 2 * i);
    }
    cout << ans << "\n";
    return 0;
}
0