結果

問題 No.2806 Cornflake Man
ユーザー suzuishisuzuishi
提出日時 2024-07-12 23:48:37
言語 Ruby
(3.3.0)
結果
AC  
実行時間 777 ms / 2,000 ms
コード長 329 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 39,452 KB
最終ジャッジ日時 2024-07-17 20:27:54
合計ジャッジ時間 6,816 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 198 ms
27,776 KB
testcase_01 AC 544 ms
35,692 KB
testcase_02 AC 118 ms
15,616 KB
testcase_03 AC 597 ms
36,572 KB
testcase_04 AC 114 ms
15,232 KB
testcase_05 AC 176 ms
17,920 KB
testcase_06 AC 151 ms
20,992 KB
testcase_07 AC 699 ms
37,888 KB
testcase_08 AC 148 ms
20,352 KB
testcase_09 AC 382 ms
27,392 KB
testcase_10 AC 247 ms
19,456 KB
testcase_11 AC 114 ms
13,056 KB
testcase_12 AC 285 ms
21,248 KB
testcase_13 AC 493 ms
30,336 KB
testcase_14 AC 172 ms
16,512 KB
testcase_15 AC 777 ms
39,452 KB
testcase_16 AC 93 ms
12,288 KB
testcase_17 AC 91 ms
12,288 KB
testcase_18 AC 93 ms
12,288 KB
testcase_19 AC 93 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:11: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:2: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

require 'set'
n, m = gets.split.map &:to_i
a = gets.split.map(&:to_i).sort
s = Set.new a.filter {|i| i > 0}
b = []
a.each do |i|
  next if i == 0 || !s.include?(i)
  s.delete i
  i.step(m, i) do |j|
    if a.bsearch {|k| j - k}.nil? then
      puts -1
      exit
    end
    s.delete j
  end
  b << i
end
puts b.size
puts b * ' '
0