結果

問題 No.1884 Sequence
ユーザー harurunharurun
提出日時 2022-03-25 22:59:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,308 bytes
コンパイル時間 3,515 ms
コンパイル使用メモリ 180,512 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-22 07:50:08
合計ジャッジ時間 8,265 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 WA -
testcase_10 AC 145 ms
6,940 KB
testcase_11 AC 145 ms
6,940 KB
testcase_12 AC 27 ms
6,944 KB
testcase_13 AC 28 ms
6,944 KB
testcase_14 AC 27 ms
6,944 KB
testcase_15 AC 89 ms
6,944 KB
testcase_16 AC 142 ms
6,940 KB
testcase_17 AC 61 ms
6,944 KB
testcase_18 AC 88 ms
6,944 KB
testcase_19 AC 70 ms
6,944 KB
testcase_20 AC 77 ms
6,940 KB
testcase_21 AC 58 ms
6,944 KB
testcase_22 AC 82 ms
6,940 KB
testcase_23 AC 144 ms
6,944 KB
testcase_24 AC 143 ms
6,940 KB
testcase_25 AC 136 ms
6,944 KB
testcase_26 AC 142 ms
6,944 KB
testcase_27 AC 32 ms
6,944 KB
testcase_28 AC 32 ms
6,940 KB
testcase_29 AC 32 ms
6,944 KB
testcase_30 AC 33 ms
6,944 KB
testcase_31 AC 75 ms
6,944 KB
testcase_32 WA -
testcase_33 AC 127 ms
6,940 KB
testcase_34 AC 127 ms
6,940 KB
testcase_35 AC 39 ms
6,940 KB
testcase_36 AC 94 ms
6,940 KB
testcase_37 AC 129 ms
6,944 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 116 ms
6,944 KB
testcase_42 AC 115 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <stdio.h>
#include <math.h>
#include <assert.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;
using ll=long long;

long long gcd(long long x,long long y){
  long long tmp;
  while(y!=0){
    tmp=y;
    y=x%y;
    x=tmp;
  }
  return x;
}

int main(){
  ll N;
  cin>>N;
  vector<ll>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  ll cnt=0;
  vector<ll> B;
  B.reserve(N);
  for(int i=0;i<N;i++){
    if(A[i]==0){
      cnt++;
    }else{
      B.emplace_back(A[i]);
    }
  }
  sort(B.begin(),B.end());
  ll sa=0;
  for(int i=0;i<(int)B.size()-1;i++){
    sa=gcd(sa,B[i+1]-B[i]);
  }
  if(sa==0){
    for(ll i:B){
      if(i!=B[0]){
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
    return 0;
  }
  ll must=0;
  for(int i=0;i<(int)B.size()-1;i++){
    if((B[i+1]-B[i])%sa){
      cout<<"No"<<endl;
      return 0;
    }
    must+=(B[i+1]-B[i])/sa-1;
  }
  //cerr<<sa<<" "<<must<<" "<<cnt<<endl;
  if(must>cnt){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
}
0