結果

問題 No.1884 Sequence
ユーザー erbowlerbowl
提出日時 2022-08-10 14:41:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 1,123 bytes
コンパイル時間 2,348 ms
コンパイル使用メモリ 208,508 KB
実行使用メモリ 8,036 KB
最終ジャッジ日時 2023-10-21 00:46:40
合計ジャッジ時間 7,321 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 147 ms
8,036 KB
testcase_11 AC 147 ms
8,036 KB
testcase_12 AC 25 ms
4,348 KB
testcase_13 AC 28 ms
4,348 KB
testcase_14 AC 27 ms
4,348 KB
testcase_15 AC 85 ms
5,676 KB
testcase_16 AC 138 ms
8,036 KB
testcase_17 AC 59 ms
4,628 KB
testcase_18 AC 84 ms
5,676 KB
testcase_19 AC 68 ms
5,412 KB
testcase_20 AC 73 ms
5,412 KB
testcase_21 AC 55 ms
4,364 KB
testcase_22 AC 79 ms
5,412 KB
testcase_23 AC 138 ms
8,036 KB
testcase_24 AC 138 ms
8,036 KB
testcase_25 AC 132 ms
8,036 KB
testcase_26 AC 138 ms
8,036 KB
testcase_27 AC 31 ms
4,348 KB
testcase_28 AC 30 ms
4,348 KB
testcase_29 AC 30 ms
4,348 KB
testcase_30 AC 30 ms
4,348 KB
testcase_31 AC 71 ms
5,412 KB
testcase_32 AC 133 ms
7,772 KB
testcase_33 AC 121 ms
5,412 KB
testcase_34 AC 120 ms
5,412 KB
testcase_35 AC 37 ms
4,348 KB
testcase_36 AC 88 ms
4,364 KB
testcase_37 AC 121 ms
5,412 KB
testcase_38 AC 109 ms
5,412 KB
testcase_39 AC 49 ms
4,348 KB
testcase_40 AC 53 ms
4,348 KB
testcase_41 AC 112 ms
7,508 KB
testcase_42 AC 112 ms
7,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ll n;
    std::cin >> n;
    vector<ll> a;
    ll zc=0;
    for (int i = 0; i < n; i++) {
        ll tmp;
        std::cin >> tmp;
        if(tmp==0){
            zc++;
        }else{
            a.push_back(tmp);
        }
    }
    if(zc==n){
        std::cout << "Yes" << std::endl;
        return 0;
    }
    bool same=false;
    sort(a.begin(),a.end());
    vector<ll> dif;
    ll gcdv = 0;
    for (int i = 0; i < a.size()-1; i++) {
        if(a[i+1]-a[i]!=0){
            gcdv = gcd(gcdv,a[i+1]-a[i]);
            dif.push_back(a[i+1]-a[i]);
        }else{
            same=true;
        }
    }
    ll req = 0;
    for (auto e : dif) {
        req += e/gcdv-1;
    }
    if(same){
        if(a.front()!=a.back()){
            std::cout << "No" << std::endl;
        }else{
            std::cout << "Yes" << std::endl;
        }
    }else{
        if(req>zc){
            std::cout << "No" << std::endl;
        }else{
            std::cout << "Yes" << std::endl;
        }
    }
}
0