結果

問題 No.1884 Sequence
ユーザー erbowlerbowl
提出日時 2022-08-10 14:39:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,043 bytes
コンパイル時間 1,914 ms
コンパイル使用メモリ 208,248 KB
実行使用メモリ 8,052 KB
最終ジャッジ日時 2023-10-21 00:44:33
合計ジャッジ時間 6,444 ms
ジャッジサーバーID
(参考情報)
judge13 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 RE -
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 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 136 ms
8,052 KB
testcase_11 AC 140 ms
8,052 KB
testcase_12 AC 23 ms
4,348 KB
testcase_13 AC 25 ms
4,348 KB
testcase_14 AC 24 ms
4,348 KB
testcase_15 AC 77 ms
5,692 KB
testcase_16 AC 122 ms
8,052 KB
testcase_17 AC 54 ms
4,644 KB
testcase_18 AC 78 ms
5,692 KB
testcase_19 AC 63 ms
5,428 KB
testcase_20 AC 67 ms
5,428 KB
testcase_21 AC 54 ms
4,380 KB
testcase_22 AC 70 ms
5,428 KB
testcase_23 AC 130 ms
8,052 KB
testcase_24 AC 124 ms
8,052 KB
testcase_25 AC 119 ms
8,052 KB
testcase_26 AC 120 ms
8,052 KB
testcase_27 RE -
testcase_28 AC 27 ms
4,348 KB
testcase_29 AC 27 ms
4,348 KB
testcase_30 AC 29 ms
4,348 KB
testcase_31 AC 65 ms
5,428 KB
testcase_32 AC 116 ms
7,788 KB
testcase_33 AC 113 ms
5,428 KB
testcase_34 AC 110 ms
5,428 KB
testcase_35 AC 33 ms
4,348 KB
testcase_36 AC 79 ms
4,380 KB
testcase_37 AC 107 ms
5,428 KB
testcase_38 AC 101 ms
5,428 KB
testcase_39 AC 47 ms
4,348 KB
testcase_40 AC 48 ms
4,348 KB
testcase_41 AC 100 ms
7,524 KB
testcase_42 AC 98 ms
7,524 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);
        }
    }
    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