結果

問題 No.1884 Sequence
コンテスト
ユーザー roaris
提出日時 2022-03-25 23:49:53
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 136 ms / 2,000 ms
+ 86µs
コード長 486 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 82 ms
コンパイル使用メモリ 64,764 KB
実行使用メモリ 89,192 KB
最終ジャッジ日時 2026-10-30 02:20:07
合計ジャッジ時間 6,923 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline
from math import gcd

N = int(input())
A = list(map(int, input().split()))
l = [Ai for Ai in A if Ai>0]
l.sort()

if len(l)==0 or l[0]==l[-1]:
    exit(print('Yes'))
    
G = 0

for i in range(len(l)-1):
    if l[i]==l[i+1]:
        exit(print('No'))
        
    G = gcd(G, l[i+1]-l[i])

if G==0:
    exit(print('Yes'))
    
cnt = 0

for i in range(len(l)-1):
    cnt += (l[i+1]-l[i])//G-1

if cnt<=N-len(l):
    print('Yes')
else:
    print('No')
0