結果

問題 No.1884 Sequence
ユーザー planesplanes
提出日時 2022-03-25 21:39:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 986 bytes
コンパイル時間 1,611 ms
コンパイル使用メモリ 170,748 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2023-08-04 08:30:57
合計ジャッジ時間 6,054 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 126 ms
6,820 KB
testcase_11 AC 124 ms
6,672 KB
testcase_12 AC 22 ms
4,424 KB
testcase_13 AC 26 ms
4,420 KB
testcase_14 AC 23 ms
4,376 KB
testcase_15 AC 78 ms
5,568 KB
testcase_16 AC 127 ms
6,688 KB
testcase_17 AC 55 ms
5,380 KB
testcase_18 AC 75 ms
5,564 KB
testcase_19 AC 62 ms
5,340 KB
testcase_20 AC 65 ms
5,604 KB
testcase_21 AC 51 ms
5,156 KB
testcase_22 AC 73 ms
5,588 KB
testcase_23 AC 124 ms
6,632 KB
testcase_24 AC 128 ms
6,752 KB
testcase_25 AC 119 ms
6,632 KB
testcase_26 AC 126 ms
6,732 KB
testcase_27 AC 28 ms
4,576 KB
testcase_28 AC 29 ms
4,664 KB
testcase_29 AC 28 ms
4,548 KB
testcase_30 AC 30 ms
4,724 KB
testcase_31 AC 65 ms
5,468 KB
testcase_32 AC 119 ms
6,584 KB
testcase_33 AC 108 ms
6,592 KB
testcase_34 AC 110 ms
6,676 KB
testcase_35 AC 35 ms
4,864 KB
testcase_36 AC 83 ms
5,704 KB
testcase_37 AC 115 ms
6,748 KB
testcase_38 AC 104 ms
6,672 KB
testcase_39 AC 47 ms
5,316 KB
testcase_40 AC 51 ms
5,308 KB
testcase_41 AC 99 ms
6,584 KB
testcase_42 AC 98 ms
6,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
int main() {
  ll N;cin>>N;
  vector<ll> A(N);
  for(ll i=0;i<N;i++) cin>>A[i];
  vector<ll> B(0);
  ll count=0;

  for(ll i=0;i<N;i++) {
    if(A[i]>0) B.push_back(A[i]);
  else count++;
  }
  sort(all(B));
if(B.size()<=2) {
  cout<<"Yes"<<endl;
  return 0;
}

ll d=B[1]-B[0];
if(d==0) {
  for(ll i=1;i<B.size()-1;i++) {
    if(B[i+1]-B[i]!=0) {
      cout<<"No"<<endl;
      return 0;
    }
  }

  cout<<"Yes"<<endl;
  return 0;
}


for(ll i=1;i<B.size()-1;i++) {
  if(B[i+1]-B[i]==0) {
    cout<<"No"<<endl;
    return 0;
  }
  d=GCD(d,B[i+1]-B[i]);
}

for(ll i=0;i<B.size()-1;i++) {
  count-=((B[i+1]-B[i])/d-1);
  if(count<0) {
    cout<<"No"<<endl;
    return 0;
  }
}

cout<<"Yes"<<endl;
}



0