結果

問題 No.2451 Redistribute Integers
ユーザー PAKACHUPAKACHU
提出日時 2023-09-01 21:35:54
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 244 ms / 2,000 ms
コード長 802 bytes
コンパイル時間 2,021 ms
コンパイル使用メモリ 136,320 KB
実行使用メモリ 7,176 KB
最終ジャッジ日時 2023-09-01 21:36:03
合計ジャッジ時間 5,024 ms
ジャッジサーバーID
(参考情報)
judge12 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 234 ms
7,176 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 154 ms
4,976 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 82 ms
4,852 KB
testcase_13 AC 219 ms
7,112 KB
testcase_14 AC 242 ms
7,096 KB
testcase_15 AC 123 ms
5,196 KB
testcase_16 AC 92 ms
4,376 KB
testcase_17 AC 181 ms
6,648 KB
testcase_18 AC 217 ms
7,168 KB
testcase_19 AC 20 ms
4,380 KB
testcase_20 AC 159 ms
4,668 KB
testcase_21 AC 244 ms
7,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const long long mod = 998244353;
const ll inf = 1LL << 60;
const int INF = 5e8;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    ll s = accumulate(a.begin(), a.end(), 0LL);
    if (s % n) {
        cout << "No" << endl;
        return 0;
    }

    sort(a.begin(), a.end());
    vector<int> b;
    for (int i = 0; i < n - 1; i++) {
        b.push_back(a[i + 1] - a[i]);
    }

    for (auto i : b) {
        if (i % n) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}
0