結果

問題 No.972 選び方のスコア
ユーザー face4face4
提出日時 2020-01-17 22:47:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 757 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 75,840 KB
実行使用メモリ 6,532 KB
最終ジャッジ日時 2023-09-08 05:44:28
合計ジャッジ時間 5,047 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
6,200 KB
testcase_01 AC 112 ms
6,336 KB
testcase_02 AC 103 ms
6,036 KB
testcase_03 AC 51 ms
4,772 KB
testcase_04 AC 102 ms
6,152 KB
testcase_05 WA -
testcase_06 AC 100 ms
6,196 KB
testcase_07 AC 82 ms
5,492 KB
testcase_08 AC 92 ms
6,172 KB
testcase_09 AC 88 ms
5,884 KB
testcase_10 AC 73 ms
6,200 KB
testcase_11 AC 78 ms
6,448 KB
testcase_12 AC 80 ms
6,156 KB
testcase_13 WA -
testcase_14 AC 76 ms
6,352 KB
testcase_15 AC 94 ms
6,200 KB
testcase_16 AC 98 ms
6,144 KB
testcase_17 AC 98 ms
6,320 KB
testcase_18 WA -
testcase_19 AC 96 ms
6,316 KB
testcase_20 AC 93 ms
6,328 KB
testcase_21 AC 95 ms
6,288 KB
testcase_22 WA -
testcase_23 AC 93 ms
6,156 KB
testcase_24 AC 94 ms
6,296 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<ll> v(n+1, 0);
    for(int i = 1; i <= n; i++)  cin >> v[i];
    sort(v.begin(), v.end());
    vector<ll> sum = v;
    for(int i = 1; i <= n; i++) sum[i] += sum[i-1];
    ll ans = 0;
    for(int i = 2; i < n; i++){
        if(v[n]-v[i]+v[i-1]-v[i] <= 0)   continue;
        int l = 1, r = min(i-1, n-i)+1;
        while(r-l > 1){
            int mid = (l+r)/2;
            if(v[n-mid-1]-v[i]+v[i-mid]-v[i] > 0)   l = mid;
            else                                    r = mid;
        }
        ans = max(ans, sum[n]-sum[n-l]+sum[i-1]-sum[i-1-l]-2*l*v[i]);
    }
    cout << ans << endl;
    return 0;
}
0