結果

問題 No.1884 Sequence
ユーザー nawawannawawan
提出日時 2022-03-25 21:35:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 1,001 bytes
コンパイル時間 2,127 ms
コンパイル使用メモリ 200,536 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 06:14:53
合計ジャッジ時間 6,859 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 137 ms
5,376 KB
testcase_11 AC 135 ms
5,376 KB
testcase_12 AC 28 ms
5,376 KB
testcase_13 AC 30 ms
5,376 KB
testcase_14 AC 27 ms
5,376 KB
testcase_15 AC 84 ms
5,376 KB
testcase_16 AC 133 ms
5,376 KB
testcase_17 AC 60 ms
5,376 KB
testcase_18 AC 87 ms
5,376 KB
testcase_19 AC 68 ms
5,376 KB
testcase_20 AC 72 ms
5,376 KB
testcase_21 AC 55 ms
5,376 KB
testcase_22 AC 77 ms
5,376 KB
testcase_23 AC 131 ms
5,376 KB
testcase_24 AC 128 ms
5,376 KB
testcase_25 AC 124 ms
5,376 KB
testcase_26 AC 131 ms
5,376 KB
testcase_27 AC 34 ms
5,376 KB
testcase_28 AC 33 ms
5,376 KB
testcase_29 AC 33 ms
5,376 KB
testcase_30 AC 34 ms
5,376 KB
testcase_31 AC 68 ms
5,376 KB
testcase_32 AC 124 ms
5,376 KB
testcase_33 AC 118 ms
5,376 KB
testcase_34 AC 117 ms
5,376 KB
testcase_35 AC 39 ms
5,376 KB
testcase_36 AC 91 ms
5,376 KB
testcase_37 AC 119 ms
5,376 KB
testcase_38 AC 107 ms
5,376 KB
testcase_39 AC 50 ms
5,376 KB
testcase_40 AC 54 ms
5,376 KB
testcase_41 AC 107 ms
5,376 KB
testcase_42 AC 111 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    long long g = -1;
    for(int i = 0; i < N; i++){
        if(A[i] == 0) continue;
        else if(i < N - 1){
            if(g == -1) g = A[i + 1] - A[i];
            else {
                if((g ==0 && A[i + 1] - A[i] != 0) || (g != 0 && A[i + 1] - A[i] == 0)){
                    cout << "No" << endl;
                    return 0;
                }
                g = gcd(g, A[i + 1] - A[i]);
            }
        }
    }
    if(g == 0){
        cout << "Yes" << endl;
        return 0;
    }
    long long cnt = 0;
    long long sz = 0;
    for(int i = 0; i < N; i++){
        if(A[i] == 0){
            cnt++;
            continue;
        }
        else if(i < N - 1){
            sz += (A[i + 1] - A[i]) / g - 1;
        }
    }
    if(sz <= cnt) cout << "Yes" << endl;
    else cout << "No" << endl;
}
0