結果

問題 No.609 Noelちゃんと星々
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-03-19 01:16:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 600 bytes
コンパイル時間 859 ms
コンパイル使用メモリ 66,008 KB
実行使用メモリ 11,472 KB
最終ジャッジ日時 2023-09-27 01:51:03
合計ジャッジ時間 5,598 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>

using ll = long long;
using namespace std;

const int MOD = 1e9+7;

int main() {
    int N;
    ll ave = 0, ans = (1LL << 62);
    cin >> N;
    vector<ll> Y(N);
    for(int i = 0; i < N; i++)
    {
        cin >> Y[i];
        ave += Y[i];
    }
    ave /= N;
    ll sum;
    do
    {
        sum = 0;
        for(int i = 0; i < N; i++)
        {
            sum += abs(Y[i] - ave);
        }
        ans = min(ans, sum);
        ave++;
    } while (sum == ans);
    cout << ans << endl;
    return 0;
}
0