結果

問題 No.1884 Sequence
ユーザー kokatsu
提出日時 2022-03-25 21:40:23
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 446 bytes
コンパイル時間 2,360 ms
コンパイル使用メモリ 214,464 KB
実行使用メモリ 14,372 KB
最終ジャッジ日時 2024-06-22 14:40:09
合計ジャッジ時間 6,704 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35 WA * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`

ソースコード

diff #

import std;

void main() {
    long N;
    readf("%d\n", N);

    auto A = readln.chomp.split.to!(long[]);

    A.sort!"a > b";

    long mx = A[0], mn = A[0];
    long[] B;
    foreach (i; 1 .. N) {
        if (A[i] == 0) break;

        B ~= A[i-1] - A[i];
        mn = min(mn, A[i]);
    }

    bool isOK = true;
    if (!B.empty) {
        long g = B.fold!gcd;
        isOK = mx <= mn + g * (N - 1);
    }

    writeln(isOK ? "Yes" : "No");
}
0