結果

問題 No.1884 Sequence
ユーザー umezoumezo
提出日時 2022-03-25 21:35:16
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 774 bytes
コンパイル時間 2,590 ms
コンパイル使用メモリ 205,488 KB
実行使用メモリ 15,744 KB
最終ジャッジ日時 2024-04-22 06:14:09
合計ジャッジ時間 6,958 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 178 ms
15,620 KB
testcase_11 AC 181 ms
15,616 KB
testcase_12 AC 12 ms
5,376 KB
testcase_13 AC 12 ms
5,376 KB
testcase_14 AC 13 ms
5,376 KB
testcase_15 AC 77 ms
10,112 KB
testcase_16 AC 162 ms
15,616 KB
testcase_17 AC 37 ms
8,064 KB
testcase_18 AC 61 ms
11,008 KB
testcase_19 AC 47 ms
9,244 KB
testcase_20 AC 60 ms
8,832 KB
testcase_21 AC 41 ms
7,428 KB
testcase_22 AC 67 ms
9,476 KB
testcase_23 AC 167 ms
15,616 KB
testcase_24 AC 168 ms
15,744 KB
testcase_25 AC 170 ms
15,744 KB
testcase_26 AC 173 ms
15,744 KB
testcase_27 AC 14 ms
5,376 KB
testcase_28 AC 14 ms
5,376 KB
testcase_29 AC 14 ms
5,376 KB
testcase_30 AC 14 ms
5,376 KB
testcase_31 AC 53 ms
9,072 KB
testcase_32 AC 136 ms
15,100 KB
testcase_33 AC 42 ms
7,036 KB
testcase_34 AC 42 ms
7,044 KB
testcase_35 AC 17 ms
5,376 KB
testcase_36 AC 34 ms
6,016 KB
testcase_37 AC 43 ms
6,944 KB
testcase_38 AC 40 ms
7,040 KB
testcase_39 AC 22 ms
5,504 KB
testcase_40 AC 23 ms
5,376 KB
testcase_41 AC 115 ms
12,928 KB
testcase_42 AC 117 ms
13,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  ll cnt=0;
  vector<ll> B;
  set<ll> s;
  rep(i,n){
    if(A[i]==0) cnt++;
    else{
      B.push_back(A[i]);
      s.insert(A[i]);
    }
  }
  if(s.size()<2) cout<<"Yes"<<endl;
  else if(s.size()!=n-cnt) cout<<"No"<<endl;
  else{
    sort(ALL(B));
    ll d=0;
    ll b=B.size();
    rep(i,b-1){
      d=gcd(d,B[i+1]-B[i]);
    }
    if(d==0) cout<<"Yes"<<endl;
    else{
      ll m=(B[b-1]-B[0])/d-1;
      if(m>n-2) cout<<"No"<<endl;
      else cout<<"Yes"<<endl;
    }
  }
   
  return 0;
}
0