結果

問題 No.1884 Sequence
ユーザー gucci0512gucci0512
提出日時 2022-03-25 21:51:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,112 bytes
コンパイル時間 3,714 ms
コンパイル使用メモリ 231,488 KB
実行使用メモリ 17,792 KB
最終ジャッジ日時 2024-04-22 06:32:41
合計ジャッジ時間 9,722 ms
ジャッジサーバーID
(参考情報)
judge3 / 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 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 303 ms
17,536 KB
testcase_11 AC 268 ms
17,664 KB
testcase_12 AC 29 ms
5,376 KB
testcase_13 AC 31 ms
5,376 KB
testcase_14 AC 33 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 278 ms
17,536 KB
testcase_17 AC 81 ms
8,832 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 268 ms
17,664 KB
testcase_24 AC 267 ms
17,536 KB
testcase_25 WA -
testcase_26 AC 268 ms
17,664 KB
testcase_27 AC 34 ms
5,376 KB
testcase_28 AC 32 ms
5,376 KB
testcase_29 AC 33 ms
5,376 KB
testcase_30 WA -
testcase_31 AC 104 ms
10,112 KB
testcase_32 AC 248 ms
16,896 KB
testcase_33 AC 116 ms
5,376 KB
testcase_34 AC 114 ms
5,376 KB
testcase_35 AC 37 ms
5,376 KB
testcase_36 AC 82 ms
5,376 KB
testcase_37 AC 113 ms
5,376 KB
testcase_38 AC 102 ms
5,376 KB
testcase_39 AC 47 ms
5,376 KB
testcase_40 AC 51 ms
5,376 KB
testcase_41 WA -
testcase_42 AC 207 ms
14,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b) for(int i=b-1;i>=0;i--)
#define rbit(i,a) for(int i=0;i<(1<<a);i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
typedef long long ll;
typedef long double lld;
using namespace std;
using namespace atcoder;
using mint=static_modint<1000000007>;
const ll mod=998244353;
//const ll mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const string zton="0123456789";
const string atoz="abcdefghijklmnopqrstuvwxyz";
ll gcd(ll a,ll b){
    ll r;
    r=a%b;
    if(r==0){
        return b;
    }
    else{
        return gcd(b,r);
    }
}
typedef pair<ll,int> P;

int main(void){
    int N;cin >> N;
    ll A[N];
    int zero=0;
    map<ll,int> s;
    rep(i,0,N){
        cin >> A[i];
        if(A[i]==0)zero++;
        s[A[i]]=s[A[i]]+1;
    }
    for(auto p:s){
        if(p.second>=2){
            if(p.first==0)continue;
            if(s.size()==1){
                cout << "Yes" << endl;
                return 0;
            }
            if(s.size()==2){
                if(s.count(0)){
                    cout << "Yes" << endl;
                }
                else{
                    cout << "No" << endl;
                }
                return 0;
            }
            cout << "No" << endl;
            return 0;
        }
    }
    sort(A,A+N);
    ll d=-1;
    ll sum=0;
    ll cnt=0;
    rep(i,0,N-1){
        if(A[i]!=0&&A[i]!=A[i+1]){
            if(d==-1){
                d=A[i+1]-A[i];
                sum+=(A[i+1]-A[i]);
                cnt++;
            }
            else{
                ll d=gcd(d,A[i+1]-A[i]);
                sum+=(A[i+1]-A[i]);
                cnt++;
            }
        }
    }
    if(d==-1){
        cout << "Yes" << endl;
        return 0;
    }
    sum-=(cnt*d);
    sum/=d;
    if(sum<=zero){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}
0