結果

問題 No.1884 Sequence
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2022-03-25 21:33:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 753 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 82,528 KB
実行使用メモリ 118,728 KB
最終ジャッジ日時 2024-04-22 06:11:46
合計ジャッジ時間 6,717 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,224 KB
testcase_01 AC 39 ms
52,224 KB
testcase_02 AC 39 ms
52,096 KB
testcase_03 AC 39 ms
51,840 KB
testcase_04 AC 39 ms
52,352 KB
testcase_05 AC 39 ms
52,316 KB
testcase_06 AC 39 ms
51,968 KB
testcase_07 AC 39 ms
51,968 KB
testcase_08 AC 38 ms
52,352 KB
testcase_09 AC 39 ms
52,096 KB
testcase_10 AC 190 ms
118,208 KB
testcase_11 AC 188 ms
118,080 KB
testcase_12 AC 73 ms
90,368 KB
testcase_13 AC 76 ms
93,952 KB
testcase_14 AC 83 ms
92,544 KB
testcase_15 AC 129 ms
108,032 KB
testcase_16 AC 158 ms
118,172 KB
testcase_17 AC 100 ms
106,240 KB
testcase_18 AC 109 ms
108,544 KB
testcase_19 AC 101 ms
104,604 KB
testcase_20 AC 123 ms
107,136 KB
testcase_21 AC 110 ms
106,112 KB
testcase_22 AC 124 ms
107,412 KB
testcase_23 AC 157 ms
118,416 KB
testcase_24 AC 156 ms
118,168 KB
testcase_25 AC 155 ms
117,432 KB
testcase_26 AC 155 ms
118,728 KB
testcase_27 AC 79 ms
97,152 KB
testcase_28 AC 80 ms
97,024 KB
testcase_29 AC 79 ms
97,536 KB
testcase_30 AC 80 ms
98,000 KB
testcase_31 AC 117 ms
102,016 KB
testcase_32 AC 161 ms
117,772 KB
testcase_33 AC 119 ms
117,000 KB
testcase_34 AC 120 ms
116,824 KB
testcase_35 AC 92 ms
102,400 KB
testcase_36 AC 127 ms
107,208 KB
testcase_37 AC 121 ms
116,696 KB
testcase_38 AC 119 ms
114,852 KB
testcase_39 AC 101 ms
105,972 KB
testcase_40 AC 104 ms
106,496 KB
testcase_41 AC 153 ms
110,844 KB
testcase_42 AC 155 ms
110,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from sys import stdin
import math

N = int(input())

A = list(map(int,input().split()))
A.sort()

d = None
z = 0
B = []

for i in range(N-1):

    if A[i] != 0:
        diff = A[i+1] - A[i]
        if d == None:
            d = diff
        else:
            d = math.gcd(d,diff)

    else:
        z += 1

for i in range(N):
    if A[i] != 0:
        B.append(A[i])

if len(B) == 0:
    print ("Yes")
    sys.exit()

if d == 0:
    if max(B) == min(B):
        print ("Yes")
    else:
        print ("No")
    sys.exit()

ind = 0
for i in range(B[0],B[-1]+1,d):

    if B[ind] == i:
        ind += 1
    else:
        z -= 1

    if z < 0:
        print ("No")
        sys.exit()

if ind == len(B):
    print ("Yes")
else:
    print ("No")
0