結果

問題 No.1884 Sequence
ユーザー customaddonecustomaddone
提出日時 2022-03-26 15:50:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 248 ms / 2,000 ms
コード長 1,373 bytes
コンパイル時間 416 ms
コンパイル使用メモリ 82,724 KB
実行使用メモリ 157,316 KB
最終ジャッジ日時 2024-04-23 07:42:20
合計ジャッジ時間 7,944 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
61,184 KB
testcase_01 AC 51 ms
61,440 KB
testcase_02 AC 54 ms
61,312 KB
testcase_03 AC 52 ms
60,928 KB
testcase_04 AC 56 ms
61,568 KB
testcase_05 AC 55 ms
61,312 KB
testcase_06 AC 53 ms
61,440 KB
testcase_07 AC 52 ms
61,056 KB
testcase_08 AC 53 ms
61,056 KB
testcase_09 AC 52 ms
61,056 KB
testcase_10 AC 248 ms
156,656 KB
testcase_11 AC 241 ms
157,316 KB
testcase_12 AC 81 ms
92,800 KB
testcase_13 AC 83 ms
96,384 KB
testcase_14 AC 87 ms
96,256 KB
testcase_15 AC 159 ms
124,820 KB
testcase_16 AC 203 ms
156,920 KB
testcase_17 AC 126 ms
112,104 KB
testcase_18 AC 139 ms
129,260 KB
testcase_19 AC 127 ms
115,968 KB
testcase_20 AC 147 ms
117,980 KB
testcase_21 AC 128 ms
109,392 KB
testcase_22 AC 150 ms
121,236 KB
testcase_23 AC 207 ms
157,052 KB
testcase_24 AC 203 ms
157,316 KB
testcase_25 AC 206 ms
156,180 KB
testcase_26 AC 212 ms
156,968 KB
testcase_27 AC 93 ms
100,736 KB
testcase_28 AC 87 ms
100,608 KB
testcase_29 AC 90 ms
100,480 KB
testcase_30 AC 87 ms
100,736 KB
testcase_31 AC 138 ms
113,892 KB
testcase_32 AC 200 ms
155,216 KB
testcase_33 AC 131 ms
123,852 KB
testcase_34 AC 130 ms
123,860 KB
testcase_35 AC 100 ms
104,576 KB
testcase_36 AC 129 ms
113,300 KB
testcase_37 AC 131 ms
123,864 KB
testcase_38 AC 139 ms
122,668 KB
testcase_39 AC 105 ms
105,728 KB
testcase_40 AC 105 ms
101,892 KB
testcase_41 AC 190 ms
142,640 KB
testcase_42 AC 184 ms
142,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque, Counter
from heapq import heapify, heappop, heappush
import math
from copy import deepcopy
from itertools import combinations, permutations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right

import sys

def input():
    return sys.stdin.readline().rstrip()
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getListGraph():
    return list(map(lambda x:int(x) - 1, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

mod = 10 ** 9 + 7
MOD = 998244353
sys.setrecursionlimit(10000000)
# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
inf = float('inf')
eps = 10 ** (-15)
dy = [0, 1, 0, -1]
dx = [1, 0, -1, 0]

#############
# Main Code #
#############

"""
等差数列
gcdする 距離を保ったまま置くことは可能か
順番は一定 ソートする
"""

N = getN()
A = sorted([i for i in getList() if i != 0])

# 全て同じ
if all([(a == A[0]) for a in A]):
    print('Yes')
    exit()

if len(A) != len(set(A)):
    print('No')
    exit()

g = 0
for i in range(len(A) - 1):
    g = math.gcd(g, A[i + 1] - A[i])
ans = 1
for i in range(len(A) - 1):
    ans += (A[i + 1] - A[i]) // g

if ans <= N:
    print('Yes')
else:
    print('No')
0