結果

問題 No.1884 Sequence
ユーザー inksamuraiinksamurai
提出日時 2022-03-25 22:04:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 1,175 bytes
コンパイル時間 2,655 ms
コンパイル使用メモリ 207,956 KB
実行使用メモリ 18,944 KB
最終ジャッジ日時 2024-04-22 06:46:19
合計ジャッジ時間 6,821 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_06 AC 2 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 160 ms
18,944 KB
testcase_11 AC 159 ms
18,816 KB
testcase_12 AC 12 ms
5,376 KB
testcase_13 AC 13 ms
5,376 KB
testcase_14 AC 13 ms
5,376 KB
testcase_15 AC 81 ms
11,776 KB
testcase_16 AC 154 ms
18,944 KB
testcase_17 AC 47 ms
8,828 KB
testcase_18 AC 82 ms
12,800 KB
testcase_19 AC 63 ms
10,568 KB
testcase_20 AC 64 ms
9,984 KB
testcase_21 AC 44 ms
8,064 KB
testcase_22 AC 72 ms
10,884 KB
testcase_23 AC 155 ms
18,812 KB
testcase_24 AC 156 ms
18,944 KB
testcase_25 AC 150 ms
18,816 KB
testcase_26 AC 152 ms
18,820 KB
testcase_27 AC 15 ms
5,376 KB
testcase_28 AC 14 ms
5,376 KB
testcase_29 AC 14 ms
5,376 KB
testcase_30 AC 15 ms
5,376 KB
testcase_31 AC 67 ms
10,336 KB
testcase_32 AC 144 ms
18,048 KB
testcase_33 AC 46 ms
7,040 KB
testcase_34 AC 46 ms
7,044 KB
testcase_35 AC 17 ms
5,376 KB
testcase_36 AC 36 ms
6,016 KB
testcase_37 AC 46 ms
6,952 KB
testcase_38 AC 42 ms
6,940 KB
testcase_39 AC 22 ms
5,376 KB
testcase_40 AC 24 ms
5,632 KB
testcase_41 AC 116 ms
15,356 KB
testcase_42 AC 118 ms
15,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define int ll

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rng(i,x,n) for(int i=x;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define vec(...) vector<__VA_ARGS__>
#define _3ulnVOy ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
using pii=pair<int,int>;
using vi=vec(int);
void print(){cout<<"\n";}
template<class T,class...E>
void print(const T&v,const E&...u){cout<<v<<' ',print(u...);}
// e

void slv(){
	int n;
	cin>>n;
	vi a(n);
	rep(i,n) cin>>a[i];
	vi na;
	int cnt=0;
	rep(i,n){
		if(a[i]>0){
			na.pb(a[i]);
		}else{
			cnt+=1;
		}
	}
	sort(na.begin(),na.end());
	if(sz(na)<=2){
		print("Yes");
		return;
	}
	std::map<int,int> mp;
	int ma=0;
	for(auto v:na){
		mp[v]+=1;
		if(mp[v]>ma){
			ma=mp[v];
		}
	}
	if(ma>1){
		print(ma!=sz(na)?"No":"Yes");
		return;
	}
	int g=0;
	rng(i,1,sz(na)){
		g=gcd(g,na[i]-na[i-1]);
	}
	rng(i,1,sz(na)){
		cnt-=((na[i]-na[i-1])/g-1);
		if(cnt<0){
			print("No");
			return;
		}
	}
	print("Yes");
}

signed main(){
_3ulnVOy;
	int t=1;
	// cin>>t;
	rep(cs,t){
		slv();
	}
//
	return 0;
}
0