結果

問題 No.837 Noelちゃんと星々2
ユーザー 東前頭十一枚目東前頭十一枚目
提出日時 2019-06-15 10:18:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 633 bytes
コンパイル時間 1,557 ms
コンパイル使用メモリ 168,916 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 19:49:58
合計ジャッジ時間 3,889 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1};
// const int dy[]={0,-1,0,1,1,-1,-1,1};

int main() {
    int64_t n; cin>>n;
    int64_t y[n]; rep(i,n) cin>>y[i];
    sort(y,y+n);
    int64_t l,r;
    int mid=n/2;
    l=y[mid/2];
    r=y[(n+mid)/2];
    if(l==r){
        cout<<1<<endl;
        return 0;
    }
    int64_t ans=0;
    rep(i,n){
        ans+=min(abs(y[i]-l),abs(y[i]-r));
    }
    cout<<ans<<endl;
    return 0;
}
0