結果

問題 No.1884 Sequence
ユーザー yvay5cqeyvay5cqe
提出日時 2022-03-28 00:55:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 779 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 34,412 KB
最終ジャッジ日時 2024-04-24 10:25:41
合計ジャッジ時間 9,042 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 AC 26 ms
10,752 KB
testcase_02 AC 25 ms
10,880 KB
testcase_03 AC 25 ms
10,880 KB
testcase_04 AC 26 ms
10,752 KB
testcase_05 AC 28 ms
10,880 KB
testcase_06 AC 25 ms
10,880 KB
testcase_07 AC 27 ms
10,880 KB
testcase_08 AC 26 ms
10,880 KB
testcase_09 WA -
testcase_10 AC 274 ms
34,308 KB
testcase_11 AC 274 ms
34,308 KB
testcase_12 AC 65 ms
13,584 KB
testcase_13 AC 66 ms
13,836 KB
testcase_14 AC 68 ms
14,280 KB
testcase_15 AC 216 ms
23,276 KB
testcase_16 AC 459 ms
34,308 KB
testcase_17 AC 160 ms
20,580 KB
testcase_18 AC 181 ms
24,712 KB
testcase_19 AC 189 ms
21,632 KB
testcase_20 AC 158 ms
21,100 KB
testcase_21 AC 128 ms
19,440 KB
testcase_22 AC 170 ms
22,220 KB
testcase_23 AC 451 ms
32,744 KB
testcase_24 AC 438 ms
34,304 KB
testcase_25 AC 301 ms
32,744 KB
testcase_26 AC 292 ms
34,412 KB
testcase_27 AC 74 ms
14,804 KB
testcase_28 AC 72 ms
14,808 KB
testcase_29 AC 71 ms
14,824 KB
testcase_30 AC 72 ms
14,808 KB
testcase_31 AC 217 ms
21,268 KB
testcase_32 AC 276 ms
33,216 KB
testcase_33 AC 244 ms
34,336 KB
testcase_34 AC 232 ms
34,332 KB
testcase_35 AC 87 ms
15,708 KB
testcase_36 AC 189 ms
26,424 KB
testcase_37 AC 187 ms
34,328 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 255 ms
28,860 KB
testcase_42 AC 349 ms
28,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
N = int(input())
A = list(map(int, input().split()))
zero_count = A.count(0)
AA = []
for x in A:
    if x != 0:
        AA.append(x)

AA.sort()
# print(zero_count, AA)
if len(AA) <= 2:
    print("Yes")
    exit()

poss = AA[1] - AA[0]
pre = -10**15
for i in range(len(AA) - 1):
    dif = AA[i + 1] - AA[i]
    poss = gcd(poss, dif)

# print(poss)
ans = True
for i in range(len(AA) - 1):
    dif = AA[i + 1] - AA[i]
    if poss == 0:
        if dif != 0:
            ans = 0
            break
        else:
            continue

    if dif % poss != 0:
        # print(dif, poss)
        ans = 0
        break
    zero_count -= dif // poss - 1
    if zero_count < 0:
        # print(-1, dif, poss)
        ans = 0
        break

print("Yes" if ans else "No")
0