結果

問題 No.1946 ロッカーの問題
ユーザー simansiman
提出日時 2022-05-24 02:07:04
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,188 ms / 3,000 ms
コード長 359 bytes
コンパイル時間 478 ms
コンパイル使用メモリ 11,884 KB
実行使用メモリ 86,912 KB
最終ジャッジ日時 2023-10-20 17:51:51
合計ジャッジ時間 10,996 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
16,028 KB
testcase_01 AC 75 ms
16,028 KB
testcase_02 AC 731 ms
68,908 KB
testcase_03 AC 1,037 ms
80,108 KB
testcase_04 AC 716 ms
68,908 KB
testcase_05 AC 508 ms
55,976 KB
testcase_06 AC 580 ms
63,556 KB
testcase_07 AC 448 ms
48,528 KB
testcase_08 AC 324 ms
32,848 KB
testcase_09 AC 986 ms
86,912 KB
testcase_10 AC 797 ms
67,804 KB
testcase_11 AC 95 ms
17,324 KB
testcase_12 AC 335 ms
36,568 KB
testcase_13 AC 74 ms
16,028 KB
testcase_14 AC 75 ms
16,028 KB
testcase_15 AC 106 ms
19,892 KB
testcase_16 AC 78 ms
16,028 KB
testcase_17 AC 498 ms
41,552 KB
testcase_18 AC 1,188 ms
83,284 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

E = Array.new(N + 1) { [] }

1.upto(N) do |i|
  i.step(N, i) do |j|
    E[j] << i
  end
end

opened = Array.new(N + 1, false)

A.each do |a|
  opened[a] = true
end

ans = 0

N.downto(1) do |i|
  if opened[i]
    E[i].each do |j|
      opened[j] ^= true
    end
  else
    ans += 1
  end
end

puts ans
0