結果

問題 No.1884 Sequence
ユーザー SSRSSSRS
提出日時 2022-03-25 21:28:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 855 bytes
コンパイル時間 1,984 ms
コンパイル使用メモリ 206,216 KB
実行使用メモリ 7,856 KB
最終ジャッジ日時 2023-08-04 08:14:50
合計ジャッジ時間 6,524 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 129 ms
7,796 KB
testcase_11 AC 130 ms
7,792 KB
testcase_12 AC 22 ms
4,488 KB
testcase_13 AC 26 ms
4,380 KB
testcase_14 AC 23 ms
4,376 KB
testcase_15 AC 78 ms
6,128 KB
testcase_16 AC 126 ms
7,780 KB
testcase_17 AC 53 ms
5,608 KB
testcase_18 AC 74 ms
6,540 KB
testcase_19 AC 59 ms
6,064 KB
testcase_20 AC 66 ms
5,868 KB
testcase_21 AC 50 ms
5,332 KB
testcase_22 AC 71 ms
6,244 KB
testcase_23 AC 123 ms
7,688 KB
testcase_24 AC 123 ms
7,816 KB
testcase_25 AC 120 ms
7,820 KB
testcase_26 AC 124 ms
7,856 KB
testcase_27 AC 28 ms
4,688 KB
testcase_28 AC 28 ms
4,560 KB
testcase_29 AC 28 ms
4,644 KB
testcase_30 AC 28 ms
4,604 KB
testcase_31 AC 63 ms
5,596 KB
testcase_32 AC 116 ms
7,632 KB
testcase_33 AC 107 ms
7,796 KB
testcase_34 AC 107 ms
7,644 KB
testcase_35 AC 32 ms
5,056 KB
testcase_36 AC 78 ms
6,656 KB
testcase_37 AC 111 ms
7,816 KB
testcase_38 AC 96 ms
7,844 KB
testcase_39 AC 44 ms
5,352 KB
testcase_40 AC 48 ms
5,392 KB
testcase_41 AC 97 ms
7,016 KB
testcase_42 AC 98 ms
6,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<long long> B;
  for (int i = 0; i < N; i++){
    if (A[i] != 0){
      B.push_back(A[i]);
    }
  }
  if (B.size() <= 1){
    cout << "Yes" << endl;
  } else if (B == vector<long long>(B.size(), B[0])){
    cout << "Yes" << endl;
  } else {
    int M = B.size();
    sort(B.begin(), B.end());
    long long g = 0;
    bool ok = true;
    for (int i = 0; i < M - 1; i++){
      g = gcd(g, B[i + 1] - B[i]);
      if (B[i] == B[i + 1]){
        ok = false;
      }
    }
    if (!ok){
      cout << "No" << endl;
    } else {
      long long cnt = (B[M - 1] - B[0]) / g + 1;
      if (cnt <= N){
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
  }
}
0