結果

問題 No.1884 Sequence
ユーザー SSRSSSRS
提出日時 2022-03-25 21:27:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 781 bytes
コンパイル時間 2,207 ms
コンパイル使用メモリ 202,120 KB
実行使用メモリ 8,172 KB
最終ジャッジ日時 2024-04-22 06:02:09
合計ジャッジ時間 6,701 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 WA -
testcase_10 AC 152 ms
7,912 KB
testcase_11 AC 152 ms
8,168 KB
testcase_12 AC 26 ms
5,376 KB
testcase_13 AC 29 ms
5,376 KB
testcase_14 AC 27 ms
5,376 KB
testcase_15 AC 90 ms
6,632 KB
testcase_16 AC 142 ms
8,040 KB
testcase_17 AC 61 ms
5,860 KB
testcase_18 AC 88 ms
6,632 KB
testcase_19 AC 70 ms
6,016 KB
testcase_20 AC 76 ms
6,124 KB
testcase_21 AC 58 ms
5,736 KB
testcase_22 AC 82 ms
6,116 KB
testcase_23 AC 144 ms
7,912 KB
testcase_24 AC 143 ms
8,040 KB
testcase_25 AC 136 ms
8,040 KB
testcase_26 AC 143 ms
8,168 KB
testcase_27 AC 32 ms
5,376 KB
testcase_28 AC 32 ms
5,376 KB
testcase_29 AC 32 ms
5,376 KB
testcase_30 AC 32 ms
5,376 KB
testcase_31 AC 74 ms
5,976 KB
testcase_32 WA -
testcase_33 AC 127 ms
8,168 KB
testcase_34 AC 127 ms
8,040 KB
testcase_35 AC 39 ms
5,376 KB
testcase_36 AC 94 ms
7,016 KB
testcase_37 AC 130 ms
8,168 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 116 ms
7,272 KB
testcase_42 AC 115 ms
7,268 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;
    for (int i = 0; i < M - 1; i++){
      g = gcd(g, B[i + 1] - B[i]);
    }
    if (g == 0){
      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