結果

問題 No.837 Noelちゃんと星々2
ユーザー ngtkanangtkana
提出日時 2020-03-13 10:03:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 807 bytes
コンパイル時間 4,596 ms
コンパイル使用メモリ 203,836 KB
実行使用メモリ 4,716 KB
最終ジャッジ日時 2023-08-13 21:54:45
合計ジャッジ時間 5,232 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
4,708 KB
testcase_01 AC 23 ms
4,576 KB
testcase_02 AC 23 ms
4,640 KB
testcase_03 AC 23 ms
4,556 KB
testcase_04 AC 24 ms
4,668 KB
testcase_05 AC 23 ms
4,636 KB
testcase_06 AC 23 ms
4,716 KB
testcase_07 AC 23 ms
4,500 KB
testcase_08 AC 23 ms
4,500 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,384 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,388 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
void cmn(lint&x,lint y){if(x>y)x=y;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    lint n;std::cin>>n;
    std::vector<lint>a(n);
    for(lint&x:a)std::cin>>x;
    std::sort(a.begin(),a.end());
    if(a.front()==a.back()){
        std::cout<<n/2<<'\n';
        return 0;
    }
    std::vector<lint>b(n+1);
    std::partial_sum(a.begin(),a.end(),b.begin()+1);
    lint ans=std::numeric_limits<lint>::max();
    for(int c=1;c<n;c++){
        int l=c/2,r=c+(n-c)/2;
        cmn(ans,
             (l-0)*a.at(l)-(b.at(l)-b.at(0))
            +(r-c)*a.at(r)-(b.at(r)-b.at(c))
            +(b.at(c)-b.at(l))-(c-l)*a.at(l)
            +(b.at(n)-b.at(r))-(n-r)*a.at(r));
    }
    std::cout<<ans<<'\n';
}
0