結果

問題 No.837 Noelちゃんと星々2
ユーザー treeonetreeone
提出日時 2019-06-14 22:15:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 682 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 204,272 KB
実行使用メモリ 4,576 KB
最終ジャッジ日時 2023-08-09 01:11:03
合計ジャッジ時間 3,776 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 WA -
testcase_18 AC 1 ms
4,384 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,384 KB
testcase_25 AC 1 ms
4,384 KB
testcase_26 AC 1 ms
4,512 KB
testcase_27 AC 2 ms
4,384 KB
testcase_28 AC 2 ms
4,384 KB
testcase_29 AC 1 ms
4,384 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,384 KB
testcase_32 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(a.begin(), a.end());
    rep(i, 1, n){
        if(a[i] != a[0]) break;
        if(i == n - 1){
            cout << 1 << endl;
            return 0;
        }
    }
    int l = n / 4;
    int r = n - 1 - n / 4;
    int ans = 0;
    rep(i, 0, n){
        ans += min(abs(a[i] - a[l]), abs(a[i] - a[r]));
    }
    cout << ans << endl;
}
0