結果

問題 No.1884 Sequence
ユーザー maimai
提出日時 2022-03-25 22:34:08
言語 Ruby
(3.3.0)
結果
AC  
実行時間 289 ms / 2,000 ms
コード長 389 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 7,168 KB
実行使用メモリ 34,048 KB
最終ジャッジ日時 2024-04-22 07:16:23
合計ジャッジ時間 10,462 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
12,160 KB
testcase_01 AC 75 ms
12,288 KB
testcase_02 AC 77 ms
12,032 KB
testcase_03 AC 77 ms
12,288 KB
testcase_04 AC 75 ms
12,032 KB
testcase_05 AC 77 ms
12,288 KB
testcase_06 AC 76 ms
12,160 KB
testcase_07 AC 77 ms
12,160 KB
testcase_08 AC 78 ms
12,160 KB
testcase_09 AC 79 ms
12,288 KB
testcase_10 AC 280 ms
33,792 KB
testcase_11 AC 278 ms
33,920 KB
testcase_12 AC 148 ms
24,192 KB
testcase_13 AC 160 ms
25,472 KB
testcase_14 AC 154 ms
24,064 KB
testcase_15 AC 225 ms
29,568 KB
testcase_16 AC 282 ms
33,920 KB
testcase_17 AC 198 ms
29,056 KB
testcase_18 AC 212 ms
29,952 KB
testcase_19 AC 195 ms
27,264 KB
testcase_20 AC 211 ms
29,312 KB
testcase_21 AC 201 ms
28,288 KB
testcase_22 AC 221 ms
29,568 KB
testcase_23 AC 289 ms
33,920 KB
testcase_24 AC 276 ms
33,920 KB
testcase_25 AC 251 ms
33,664 KB
testcase_26 AC 256 ms
34,048 KB
testcase_27 AC 167 ms
28,672 KB
testcase_28 AC 165 ms
28,928 KB
testcase_29 AC 165 ms
28,928 KB
testcase_30 AC 174 ms
28,928 KB
testcase_31 AC 200 ms
26,752 KB
testcase_32 AC 251 ms
32,384 KB
testcase_33 AC 179 ms
30,976 KB
testcase_34 AC 181 ms
30,848 KB
testcase_35 AC 172 ms
28,928 KB
testcase_36 AC 218 ms
29,312 KB
testcase_37 AC 227 ms
33,920 KB
testcase_38 AC 228 ms
32,896 KB
testcase_39 AC 183 ms
28,288 KB
testcase_40 AC 188 ms
28,160 KB
testcase_41 AC 240 ms
30,720 KB
testcase_42 AC 257 ms
30,720 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def lscan; gets.split.map(&:to_i); end

n = gets.to_i
aa = lscan.sort
bb = aa.filter{|a| a > 0}

if bb[0] == bb[-1]
  puts 'Yes'
  exit
end

d = bb.each_cons(2).map{|l,r| r-l }.reduce(&:gcd)
m = n - bb.size

bb.each_cons(2) do |l, r|
  l += d
  while l < r
    m -= 1
    l += d
    if m < 0
      puts 'No'
      exit
    end
  end
  if l != r
    puts 'No'
    exit
  end
end

puts 'Yes'
0