結果

問題 No.1884 Sequence
ユーザー 沙耶花沙耶花
提出日時 2022-03-25 21:32:43
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 291 ms / 2,000 ms
コード長 877 bytes
コンパイル時間 4,572 ms
コンパイル使用メモリ 270,024 KB
実行使用メモリ 29,756 KB
最終ジャッジ日時 2023-08-04 08:20:18
合計ジャッジ時間 11,932 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 291 ms
29,680 KB
testcase_11 AC 290 ms
29,756 KB
testcase_12 AC 91 ms
14,444 KB
testcase_13 AC 100 ms
15,428 KB
testcase_14 AC 66 ms
13,940 KB
testcase_15 AC 175 ms
17,132 KB
testcase_16 AC 256 ms
17,052 KB
testcase_17 AC 142 ms
17,092 KB
testcase_18 AC 174 ms
17,048 KB
testcase_19 AC 142 ms
15,260 KB
testcase_20 AC 150 ms
21,856 KB
testcase_21 AC 155 ms
19,972 KB
testcase_22 AC 175 ms
22,692 KB
testcase_23 AC 259 ms
17,052 KB
testcase_24 AC 257 ms
17,268 KB
testcase_25 AC 245 ms
17,000 KB
testcase_26 AC 250 ms
17,080 KB
testcase_27 AC 33 ms
4,892 KB
testcase_28 AC 33 ms
4,640 KB
testcase_29 AC 39 ms
4,712 KB
testcase_30 AC 107 ms
17,008 KB
testcase_31 AC 144 ms
14,688 KB
testcase_32 AC 239 ms
17,092 KB
testcase_33 AC 116 ms
4,748 KB
testcase_34 AC 116 ms
4,684 KB
testcase_35 AC 41 ms
4,584 KB
testcase_36 AC 88 ms
4,672 KB
testcase_37 AC 190 ms
17,060 KB
testcase_38 AC 109 ms
4,664 KB
testcase_39 AC 56 ms
4,696 KB
testcase_40 AC 60 ms
4,648 KB
testcase_41 AC 213 ms
17,148 KB
testcase_42 AC 216 ms
16,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Inf 1000000001


int main(){
	
	int n;
	cin>>n;
	
	vector<long long> a(n);
	rep(i,n){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	if(a.back()==0 || a[n-2]==0){
		cout<<"Yes"<<endl;
		return 0;
	}
	
	
	long long g = 0;
	rep(i,n){
		if(a[i]==0)continue;
		g = gcd(g,a.back()-a[i]);
	}
	map<long long,long long> mp;
	rep(i,a.size())mp[a[i]]++;
	
	long long m = a.back();
	long long M = a.back();

	rep(i,a.size()){
		if(a[i]!=0)m = min(a[i],m);
	}
	
	rep(i,n){
		if(mp[m]>0){
			mp[m]--;
		}
		else{
			mp[0]--;
		}
		m += g;
		if(m>100000000000000000)m = 100000000000000000;
	}
	for(auto x:mp){
		if(x.second!=0){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	
	return 0;
}
0