結果

問題 No.2451 Redistribute Integers
ユーザー planesplanes
提出日時 2023-09-01 21:37:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 632 bytes
コンパイル時間 1,696 ms
コンパイル使用メモリ 169,728 KB
実行使用メモリ 7,052 KB
最終ジャッジ日時 2023-09-01 21:38:03
合計ジャッジ時間 3,857 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 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 77 ms
6,984 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 58 ms
6,804 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 35 ms
4,384 KB
testcase_13 AC 87 ms
6,860 KB
testcase_14 AC 95 ms
6,984 KB
testcase_15 AC 50 ms
4,896 KB
testcase_16 AC 48 ms
4,936 KB
testcase_17 AC 77 ms
5,920 KB
testcase_18 AC 83 ms
7,052 KB
testcase_19 AC 9 ms
4,380 KB
testcase_20 AC 82 ms
6,208 KB
testcase_21 AC 103 ms
6,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

  #include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

ll INF=2e18;


int main() {
    ios::sync_with_stdio(false);
  cin.tie(0);
ll N;cin>>N;
vector<ll> A(N);
ll s=0;
for(ll i=0;i<N;i++) {
  cin>>A[i];
  s+=A[i];
}

sort(all(A));


if(s%N!=0) {
  cout<<"No"<<endl;
  return 0;
}

s/=N;
ll count=s-A[0];
ll ans=0;
for(ll i=0;i<N;i++) {
  A[i]+=count;
  if((A[i]-s)%N!=0) {
    cout<<"No"<<endl;
    return 0;
  }
  
  ans+=(A[i]-s)/N;
}

if(ans==count) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
  
0