結果

問題 No.1884 Sequence
ユーザー ygd.ygd.
提出日時 2022-03-26 10:12:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 339 ms / 2,000 ms
コード長 1,221 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 36,856 KB
最終ジャッジ日時 2024-04-23 02:39:30
合計ジャッジ時間 7,427 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
11,008 KB
testcase_01 AC 25 ms
10,880 KB
testcase_02 AC 25 ms
10,880 KB
testcase_03 AC 30 ms
10,880 KB
testcase_04 AC 27 ms
10,880 KB
testcase_05 AC 27 ms
10,880 KB
testcase_06 AC 27 ms
10,880 KB
testcase_07 AC 25 ms
10,880 KB
testcase_08 AC 26 ms
10,880 KB
testcase_09 AC 28 ms
10,880 KB
testcase_10 AC 325 ms
36,788 KB
testcase_11 AC 336 ms
36,756 KB
testcase_12 AC 62 ms
13,740 KB
testcase_13 AC 65 ms
13,996 KB
testcase_14 AC 58 ms
14,544 KB
testcase_15 AC 198 ms
24,504 KB
testcase_16 AC 339 ms
36,700 KB
testcase_17 AC 121 ms
20,576 KB
testcase_18 AC 162 ms
26,296 KB
testcase_19 AC 133 ms
23,700 KB
testcase_20 AC 154 ms
21,108 KB
testcase_21 AC 118 ms
19,556 KB
testcase_22 AC 172 ms
24,336 KB
testcase_23 AC 331 ms
36,764 KB
testcase_24 AC 331 ms
36,856 KB
testcase_25 AC 292 ms
36,656 KB
testcase_26 AC 319 ms
36,688 KB
testcase_27 AC 63 ms
14,108 KB
testcase_28 AC 61 ms
14,108 KB
testcase_29 AC 63 ms
14,236 KB
testcase_30 AC 64 ms
14,236 KB
testcase_31 AC 119 ms
24,620 KB
testcase_32 AC 214 ms
36,648 KB
testcase_33 AC 111 ms
32,752 KB
testcase_34 AC 110 ms
32,888 KB
testcase_35 AC 66 ms
15,936 KB
testcase_36 AC 108 ms
25,912 KB
testcase_37 AC 119 ms
32,884 KB
testcase_38 AC 118 ms
32,892 KB
testcase_39 AC 77 ms
18,996 KB
testcase_40 AC 82 ms
19,672 KB
testcase_41 AC 264 ms
27,964 KB
testcase_42 AC 258 ms
28,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline #文字列はダメ
#sys.setrecursionlimit(1000000)
#import bisect
#import itertools
#import random
#from heapq import heapify, heappop, heappush
#from collections import defaultdict 
#from collections import deque
#import copy
import math
#from functools import lru_cache
#@lru_cache(maxsize=None)
#MOD = pow(10,9) + 7
#MOD = 998244353
#dx = [1,0,-1,0]
#dy = [0,1,0,-1]
#dx8 = [1,1,0,-1,-1,-1,0,1]
#dy8 = [0,1,1,1,0,-1,-1,-1]

def main():
    N = int(input())
    A = list(map(int,input().split()))
    X = []
    for a in A:
        if a == 0: continue
        X.append(a)
    X.sort()
    if len(X) <= 1:
        print('Yes');exit()
    if len(set(X)) == 1:
        print('Yes');exit()
    if len(set(X)) < len(X):
        print('No');exit()
    M = len(X)
    for i in range(M-1):
        if i == 0:
            g = X[1] - X[0]
        else:
            g = math.gcd(g, X[i+1] - X[i])
    
    num = 0
    for i in range(M-1):
        num += ((X[i+1] - X[i]) // g) - 1 #間の数なので植木算
    #print(num)
    zeros = N - M
    if zeros >= num:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
0