結果

問題 No.972 選び方のスコア
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-06-20 16:32:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 586 bytes
コンパイル時間 1,256 ms
コンパイル使用メモリ 148,232 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 17:36:11
合計ジャッジ時間 5,050 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.20 16:32:07
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

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());
    ll ans = 0;
    ll x = 0;
    ll y = 0;
    ll m = a[0];
    for (int i = 1; i < n-i; i++) {
        y += (a[i] - m) * i;
        x -= (a[i] - m) * (i - 1);
        x += a[n-i] - a[i];
        ans = max(ans,x - y);
        m = a[i];
    }
    cout << ans << endl;
    return 0;
}
0