結果

問題 No.198 キャンディー・ボックス2
ユーザー kroton
提出日時 2015-03-12 23:55:45
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 350 bytes
コンパイル時間 1,404 ms
コンパイル使用メモリ 162,140 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 22:35:45
合計ジャッジ時間 2,536 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    int B, N;
    cin >> B >> N;
    
    vector<int> C(N);
    for(int i=0;i<N;i++)cin >> C[i];

    sort(C.begin(), C.end());

    int t = C[C.size() / 2];
    ll res = 0;

    for(int x : C){
        res += abs(x - t);
    }

    cout << res << endl;
    return 0;
}
0