結果
| 問題 |
No.1884 Sequence
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-03-25 21:32:24 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,126 bytes |
| コンパイル時間 | 2,408 ms |
| コンパイル使用メモリ | 198,924 KB |
| 最終ジャッジ日時 | 2025-01-28 11:42:02 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 RE * 1 |
| other | AC * 25 WA * 9 RE * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
std::cout << PREFIX << #x << " = " << x << std::endl; \
}
std::ostream& output_indent(std::ostream& os, int ind) {
for(int i = 0; i < ind; i++) os << " ";
return os;
}
template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);
template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {
return (os << "(" << p.first << ", " << p.second << ")");
}
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
os << "[";
for(int i = 0;i < v.size();i++) os << v[i] << ", ";
return (os << "]");
}
template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
i64 gcd(i64 a, i64 b) {
if(b == 0) return a;
return gcd(b, a % b);
}
int main() {
i64 N;
cin >> N;
vector<i64> A;
i64 cnt = 0;
rep(i,0,N) {
i64 a;
cin >> a;
if(a > 0) {
A.push_back(a);
}
else {
cnt++;
}
}
if(A.size() <= 1) {
cout << "Yes" << endl;
return 0;
}
sort(all(A));
i64 G = A[1] - A[0];
i64 zerod = 0;
rep(i,1,A.size()) {
G = gcd(G, A[i] - A[i - 1]);
if(A[i] - A[i - 1]){
zerod = 1;
}
}
i64 sum = 0;
if(zerod) {
if(A.front() == A.back()) {
cout << "Yes" << endl;
}
else {
cout << "No" << endl;
}
return 0;
}
rep(i,1,A.size()) {
i64 a = A[i];
i64 b = A[i - 1];
i64 c = (a - b) / G - 1;
sum += c;
}
if(sum <= cnt) {
cout << "Yes" << endl;
}
else {
cout << "No" << endl;
}
}