結果

問題 No.1884 Sequence
ユーザー Nzt3Nzt3
提出日時 2022-09-25 00:53:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 2,711 ms
コンパイル使用メモリ 204,868 KB
実行使用メモリ 5,300 KB
最終ジャッジ日時 2023-08-24 00:40:20
合計ジャッジ時間 5,940 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 65 ms
5,220 KB
testcase_11 AC 64 ms
5,092 KB
testcase_12 AC 10 ms
4,376 KB
testcase_13 AC 11 ms
4,380 KB
testcase_14 AC 10 ms
4,376 KB
testcase_15 AC 34 ms
4,376 KB
testcase_16 AC 55 ms
5,076 KB
testcase_17 AC 21 ms
4,376 KB
testcase_18 AC 29 ms
4,376 KB
testcase_19 AC 24 ms
4,380 KB
testcase_20 AC 29 ms
4,376 KB
testcase_21 AC 22 ms
4,380 KB
testcase_22 AC 32 ms
4,380 KB
testcase_23 AC 55 ms
5,148 KB
testcase_24 AC 55 ms
5,148 KB
testcase_25 AC 53 ms
5,092 KB
testcase_26 AC 54 ms
5,300 KB
testcase_27 AC 12 ms
4,376 KB
testcase_28 AC 12 ms
4,380 KB
testcase_29 AC 12 ms
4,376 KB
testcase_30 AC 12 ms
4,380 KB
testcase_31 AC 28 ms
4,376 KB
testcase_32 AC 52 ms
5,216 KB
testcase_33 AC 40 ms
5,212 KB
testcase_34 AC 40 ms
5,072 KB
testcase_35 AC 15 ms
4,380 KB
testcase_36 AC 31 ms
4,380 KB
testcase_37 AC 40 ms
5,068 KB
testcase_38 AC 37 ms
5,264 KB
testcase_39 AC 18 ms
4,380 KB
testcase_40 AC 19 ms
4,380 KB
testcase_41 AC 45 ms
5,216 KB
testcase_42 AC 46 ms
5,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector<long long>A;
  long long cnt0=0;
  for(int i=0;i<N;i++){
    long long a;
    cin>>a;
    if(a==0)++cnt0;
    else A.push_back(a);
  }
  sort(A.begin(),A.end());
  long long d=0;
  bool z=false;
  for(int i=0;i<(int)A.size()-1;i++){
    d=gcd(A[i+1]-A[i],d);
    if(A[i+1]==A[i])z=true;
  }
  if(z&&d!=0){
    cout<<"No\n";
    return 0;
  }
  if(d==0){
    cout<<"Yes\n";
    return 0;
  }
  for(int i=0;i<(int)A.size()-1;i++){
    cnt0-=(A[i+1]-A[i])/d-1;
  }
  cout<<(cnt0>=0?"Yes\n":"No\n");
}
0