結果

問題 No.1884 Sequence
ユーザー planesplanes
提出日時 2022-03-25 21:31:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 918 bytes
コンパイル時間 2,051 ms
コンパイル使用メモリ 172,112 KB
実行使用メモリ 7,272 KB
最終ジャッジ日時 2024-04-22 06:07:16
合計ジャッジ時間 6,796 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 146 ms
7,140 KB
testcase_11 AC 146 ms
7,144 KB
testcase_12 AC 27 ms
5,376 KB
testcase_13 AC 30 ms
5,376 KB
testcase_14 AC 28 ms
5,376 KB
testcase_15 AC 90 ms
5,996 KB
testcase_16 AC 145 ms
7,148 KB
testcase_17 AC 62 ms
5,504 KB
testcase_18 AC 89 ms
6,120 KB
testcase_19 AC 73 ms
5,892 KB
testcase_20 AC 77 ms
6,116 KB
testcase_21 AC 58 ms
5,376 KB
testcase_22 AC 85 ms
6,244 KB
testcase_23 AC 147 ms
7,140 KB
testcase_24 AC 144 ms
7,272 KB
testcase_25 AC 137 ms
7,016 KB
testcase_26 AC 142 ms
7,016 KB
testcase_27 AC 33 ms
5,376 KB
testcase_28 AC 33 ms
5,376 KB
testcase_29 AC 33 ms
5,376 KB
testcase_30 AC 32 ms
5,376 KB
testcase_31 AC 77 ms
5,720 KB
testcase_32 AC 138 ms
7,012 KB
testcase_33 AC 130 ms
7,144 KB
testcase_34 AC 130 ms
7,020 KB
testcase_35 AC 39 ms
5,376 KB
testcase_36 AC 96 ms
5,992 KB
testcase_37 AC 130 ms
7,012 KB
testcase_38 AC 116 ms
7,020 KB
testcase_39 AC 53 ms
5,632 KB
testcase_40 WA -
testcase_41 AC 117 ms
7,012 KB
testcase_42 AC 118 ms
7,016 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++) {
  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