結果

問題 No.972 選び方のスコア
ユーザー amotoma3amotoma3
提出日時 2020-01-25 15:38:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 995 bytes
コンパイル時間 1,440 ms
コンパイル使用メモリ 171,652 KB
実行使用メモリ 4,856 KB
最終ジャッジ日時 2023-10-12 04:34:58
合計ジャッジ時間 3,989 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
4,584 KB
testcase_01 AC 41 ms
4,620 KB
testcase_02 AC 39 ms
4,636 KB
testcase_03 AC 20 ms
4,348 KB
testcase_04 AC 40 ms
4,696 KB
testcase_05 AC 39 ms
4,564 KB
testcase_06 AC 39 ms
4,668 KB
testcase_07 AC 30 ms
4,404 KB
testcase_08 AC 28 ms
4,596 KB
testcase_09 AC 27 ms
4,592 KB
testcase_10 AC 27 ms
4,640 KB
testcase_11 AC 28 ms
4,568 KB
testcase_12 AC 28 ms
4,568 KB
testcase_13 AC 28 ms
4,572 KB
testcase_14 AC 28 ms
4,856 KB
testcase_15 AC 29 ms
4,664 KB
testcase_16 AC 29 ms
4,676 KB
testcase_17 AC 29 ms
4,636 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,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,352 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(){
    ll n;cin>>n;
    vec a(n);
    rep(i,n)cin>>a[i];

    if(n<=2){
        cout<<0<<endl;
        return;
    }

    sort(all(a));
    ll ans=0;
    ll sum=0;
    rep(i,(n-1)/2){
        sum+=a[i]+a[n-1-i];
        chmax(ans,sum-a[i+1]*(i+1)*2);
    }
    cout<<ans<<endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    solve();
}
0