結果

問題 No.1884 Sequence
ユーザー silv723silv723
提出日時 2022-03-25 21:51:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 771 bytes
コンパイル時間 2,070 ms
コンパイル使用メモリ 200,940 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 06:32:29
合計ジャッジ時間 6,275 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 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 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 140 ms
5,376 KB
testcase_11 AC 141 ms
5,376 KB
testcase_12 AC 27 ms
5,376 KB
testcase_13 AC 29 ms
5,376 KB
testcase_14 AC 28 ms
5,376 KB
testcase_15 AC 80 ms
5,376 KB
testcase_16 AC 128 ms
5,376 KB
testcase_17 AC 59 ms
5,376 KB
testcase_18 AC 83 ms
5,376 KB
testcase_19 AC 68 ms
5,376 KB
testcase_20 AC 75 ms
5,376 KB
testcase_21 AC 56 ms
5,376 KB
testcase_22 AC 78 ms
5,376 KB
testcase_23 AC 130 ms
5,376 KB
testcase_24 AC 128 ms
5,376 KB
testcase_25 AC 121 ms
5,376 KB
testcase_26 AC 129 ms
5,376 KB
testcase_27 AC 32 ms
5,376 KB
testcase_28 AC 32 ms
5,376 KB
testcase_29 AC 31 ms
5,376 KB
testcase_30 AC 32 ms
5,376 KB
testcase_31 AC 68 ms
5,376 KB
testcase_32 AC 119 ms
5,376 KB
testcase_33 AC 113 ms
5,376 KB
testcase_34 AC 116 ms
5,376 KB
testcase_35 AC 38 ms
5,376 KB
testcase_36 AC 87 ms
5,376 KB
testcase_37 AC 114 ms
5,376 KB
testcase_38 AC 104 ms
5,376 KB
testcase_39 AC 49 ms
5,376 KB
testcase_40 AC 52 ms
5,376 KB
testcase_41 AC 107 ms
5,376 KB
testcase_42 AC 107 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
	ll n;
	cin>>n;
	vector<ll> a(n);
	ll cnt=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==0)cnt++;
	}
	sort(a.begin(),a.end());
    ll k=0;
    for(int i=0;i<n-1;i++){
		if(a[i]!=0) k=max(k,a[i+1]-a[i]);
	}
	for(int i=0;i<n-1;i++){
		if(a[i]==0||a[i+1]==0) continue;
        if(a[i+1]==a[i]){k=0;break;}
		k=gcd(k,a[i+1]-a[i]);
	}
	ll z=0;
    if(k==0){
      for(int i=0;i<n-1;i++){
		if(a[i]==a[i+1]||(a[i]==0)) continue;
        cout<<"No"<<endl;
        return 0;
	  }
      cout<<"Yes"<<endl;
      return 0;
    }
	for(int i=0;i<n-1;i++){
		if(a[i]==0||a[i+1]==0) continue;
		z+=(a[i+1]-a[i])/k-1;
    }
	//cout<<k<<" "<<z<<endl;
	if(cnt>=z) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
0