結果

問題 No.1884 Sequence
ユーザー nawawannawawan
提出日時 2022-03-25 21:31:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 964 bytes
コンパイル時間 2,537 ms
コンパイル使用メモリ 201,300 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-22 06:08:04
合計ジャッジ時間 7,448 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 151 ms
5,376 KB
testcase_11 AC 150 ms
5,376 KB
testcase_12 AC 29 ms
5,376 KB
testcase_13 AC 32 ms
5,376 KB
testcase_14 AC 32 ms
5,376 KB
testcase_15 AC 91 ms
5,376 KB
testcase_16 AC 142 ms
5,376 KB
testcase_17 AC 63 ms
5,376 KB
testcase_18 AC 89 ms
5,376 KB
testcase_19 AC 71 ms
5,376 KB
testcase_20 AC 78 ms
5,376 KB
testcase_21 AC 61 ms
5,376 KB
testcase_22 AC 84 ms
5,376 KB
testcase_23 AC 141 ms
5,376 KB
testcase_24 AC 143 ms
5,376 KB
testcase_25 AC 135 ms
5,376 KB
testcase_26 AC 142 ms
5,376 KB
testcase_27 AC 36 ms
5,376 KB
testcase_28 AC 36 ms
5,376 KB
testcase_29 AC 36 ms
5,376 KB
testcase_30 AC 36 ms
5,376 KB
testcase_31 AC 75 ms
5,376 KB
testcase_32 WA -
testcase_33 AC 127 ms
5,376 KB
testcase_34 AC 128 ms
5,376 KB
testcase_35 AC 43 ms
5,376 KB
testcase_36 AC 99 ms
5,376 KB
testcase_37 AC 129 ms
5,376 KB
testcase_38 AC 114 ms
5,376 KB
testcase_39 AC 56 ms
5,376 KB
testcase_40 WA -
testcase_41 AC 116 ms
5,376 KB
testcase_42 AC 118 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){
                    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