結果

問題 No.1884 Sequence
ユーザー silv723silv723
提出日時 2022-03-25 21:49:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 782 bytes
コンパイル時間 2,329 ms
コンパイル使用メモリ 202,788 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-22 06:29:21
合計ジャッジ時間 6,923 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 37 ms
5,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 74 ms
5,376 KB
testcase_32 AC 133 ms
5,376 KB
testcase_33 AC 127 ms
5,376 KB
testcase_34 AC 128 ms
5,376 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 127 ms
5,376 KB
testcase_38 AC 114 ms
5,376 KB
testcase_39 AC 55 ms
5,376 KB
testcase_40 AC 60 ms
5,376 KB
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

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]==0){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&&a[i+1]==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