結果

問題 No.2451 Redistribute Integers
ユーザー kpinkcatkpinkcat
提出日時 2023-10-05 02:51:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 606 bytes
コンパイル時間 996 ms
コンパイル使用メモリ 103,844 KB
実行使用メモリ 7,120 KB
最終ジャッジ日時 2023-10-05 02:51:54
合計ジャッジ時間 4,092 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 216 ms
7,120 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 147 ms
6,928 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 67 ms
4,616 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 89 ms
4,884 KB
testcase_17 AC 145 ms
6,000 KB
testcase_18 WA -
testcase_19 AC 16 ms
4,380 KB
testcase_20 AC 154 ms
5,892 KB
testcase_21 AC 193 ms
6,992 KB
権限があれば一括ダウンロードができます

ソースコード

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