結果

問題 No.1884 Sequence
ユーザー rlangevinrlangevin
提出日時 2023-01-01 14:56:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 268 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 164,908 KB
最終ジャッジ日時 2023-08-17 23:04:03
合計ジャッジ時間 8,626 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,368 KB
testcase_01 AC 72 ms
71,372 KB
testcase_02 AC 72 ms
71,104 KB
testcase_03 AC 73 ms
71,480 KB
testcase_04 AC 73 ms
71,232 KB
testcase_05 AC 73 ms
71,496 KB
testcase_06 AC 74 ms
71,536 KB
testcase_07 AC 73 ms
71,148 KB
testcase_08 AC 72 ms
71,344 KB
testcase_09 AC 73 ms
71,380 KB
testcase_10 AC 268 ms
164,772 KB
testcase_11 AC 263 ms
164,908 KB
testcase_12 AC 99 ms
98,036 KB
testcase_13 AC 104 ms
100,752 KB
testcase_14 AC 106 ms
98,296 KB
testcase_15 AC 176 ms
126,664 KB
testcase_16 AC 216 ms
164,552 KB
testcase_17 AC 135 ms
107,100 KB
testcase_18 AC 163 ms
129,676 KB
testcase_19 AC 142 ms
104,520 KB
testcase_20 AC 157 ms
107,480 KB
testcase_21 AC 138 ms
108,836 KB
testcase_22 AC 173 ms
123,548 KB
testcase_23 AC 220 ms
164,384 KB
testcase_24 AC 220 ms
164,832 KB
testcase_25 AC 226 ms
164,184 KB
testcase_26 AC 221 ms
164,704 KB
testcase_27 AC 107 ms
103,872 KB
testcase_28 AC 106 ms
104,352 KB
testcase_29 AC 108 ms
104,332 KB
testcase_30 AC 107 ms
104,472 KB
testcase_31 AC 154 ms
101,812 KB
testcase_32 AC 215 ms
163,376 KB
testcase_33 AC 139 ms
118,052 KB
testcase_34 AC 140 ms
118,040 KB
testcase_35 AC 109 ms
104,952 KB
testcase_36 AC 137 ms
106,972 KB
testcase_37 AC 151 ms
131,596 KB
testcase_38 AC 151 ms
130,380 KB
testcase_39 AC 118 ms
107,820 KB
testcase_40 AC 118 ms
106,688 KB
testcase_41 AC 203 ms
146,336 KB
testcase_42 AC 203 ms
146,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

N = int(input())
A = list(map(int, input().split()))
L = []
zero = 0
for a in A:
    if a == 0:
        zero += 1
    else:
        L.append(a)
        
L.sort()
if len(set(L)) <= 1:
    print("Yes")
    exit()
D = []
for i in range(len(L) - 1):
    D.append(L[i + 1] - L[i])
minv = D[0]
for d in D:
    minv = gcd(minv, d)
    if d == 0:
        minv = 0
        break

if minv == 0:
    print("No")
    exit()
    
cnt = 0
for d in D:
    cnt += d - 1
if cnt <= zero:
    print("Yes")
    exit()


cnt = 0
for d in D:
    if d % minv != 0:
        print("No")
        exit()
    cnt += d // minv - 1
    
if cnt <= zero:
    print("Yes")
else:
    print("No")    
0