結果

問題 No.1884 Sequence
ユーザー simansiman
提出日時 2022-03-27 09:38:43
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 455 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 35,840 KB
最終ジャッジ日時 2024-04-23 22:30:18
合計ジャッジ時間 10,195 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
12,288 KB
testcase_01 AC 73 ms
12,288 KB
testcase_02 AC 74 ms
12,160 KB
testcase_03 AC 79 ms
12,160 KB
testcase_04 AC 73 ms
12,288 KB
testcase_05 AC 74 ms
12,288 KB
testcase_06 AC 74 ms
12,288 KB
testcase_07 AC 72 ms
12,288 KB
testcase_08 AC 72 ms
12,160 KB
testcase_09 WA -
testcase_10 AC 271 ms
33,920 KB
testcase_11 AC 272 ms
34,048 KB
testcase_12 AC 175 ms
25,472 KB
testcase_13 AC 184 ms
27,008 KB
testcase_14 AC 180 ms
25,216 KB
testcase_15 AC 234 ms
30,720 KB
testcase_16 AC 261 ms
35,840 KB
testcase_17 AC 211 ms
30,720 KB
testcase_18 AC 222 ms
30,976 KB
testcase_19 AC 201 ms
28,800 KB
testcase_20 AC 228 ms
30,336 KB
testcase_21 AC 223 ms
29,440 KB
testcase_22 AC 229 ms
30,336 KB
testcase_23 AC 264 ms
35,584 KB
testcase_24 AC 268 ms
35,712 KB
testcase_25 AC 238 ms
33,920 KB
testcase_26 AC 251 ms
34,048 KB
testcase_27 AC 159 ms
28,928 KB
testcase_28 AC 162 ms
28,800 KB
testcase_29 AC 155 ms
28,928 KB
testcase_30 AC 208 ms
30,336 KB
testcase_31 AC 216 ms
28,032 KB
testcase_32 AC 247 ms
32,256 KB
testcase_33 AC 238 ms
35,712 KB
testcase_34 AC 237 ms
35,584 KB
testcase_35 AC 174 ms
29,184 KB
testcase_36 AC 215 ms
31,488 KB
testcase_37 AC 217 ms
34,304 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 239 ms
31,488 KB
testcase_42 AC 256 ms
32,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i).sort

B = A.select { |x| x > 0 }
zc = A.count(0)
range = B.each_cons(2).map { |a, b| b - a }.inject(&:gcd)

stack = []

until B.empty?
  b = B.shift
  stack << b

  if stack.size >= 2
    if stack[-1] - stack[-2] > range
      if zc > 0
        c = stack.pop
        stack << stack.last + range
        B.unshift(c)
        zc -= 1
      else
        puts 'No'
        exit
      end
    end
  end
end

puts 'Yes'
0