結果

問題 No.2451 Redistribute Integers
ユーザー kpinkcat
提出日時 2023-10-05 02:51:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 606 bytes
コンパイル時間 974 ms
コンパイル使用メモリ 104,580 KB
最終ジャッジ日時 2025-02-17 04:21:18
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;

int main(){
    ll n, cnt = 0, ave = 0, dif = 0;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
        cnt += a[i];
    }
    if (cnt%n == 0) ave = cnt/n;
    else {
        cout << "No" << endl;
        return 0;
    }
    
    for (int i = 0; i < n; i++){
        dif += abs(a[i] - ave);
    }
    cout << ((dif%n == 0) ? "Yes" : "No") << endl;
}
0