結果
問題 |
No.2402 Dirty Stairs and Shoes
|
ユーザー |
![]() |
提出日時 | 2023-08-07 18:49:50 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 377 ms / 2,000 ms |
コード長 | 663 bytes |
コンパイル時間 | 380 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 30,720 KB |
最終ジャッジ日時 | 2024-12-20 02:50:08 |
合計ジャッジ時間 | 8,855 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
コンパイルメッセージ
Syntax OK
ソースコード
N, K = gets.split.map(&:to_i) M1 = gets.to_i A = gets.split.map(&:to_i) M2 = gets.to_i B = gets.split.map(&:to_i) cleaned = Array.new(N + 1, false) dirty = Array.new(N + 1, false) A.each do |a| dirty[a] = true end B.each do |b| cleaned[b] = true end dp = Array.new(N + 1) { Array.new(2, false) } dp[0][0] = true steps = [1, K] N.times do |i| 2.times do |j| next if not dp[i][j] steps.each do |s| ni = i + s next if ni > N if dirty[ni] dp[ni][1] = true elsif cleaned[ni] dp[ni][0] = true else dp[ni][j] = dp[i][j] end end end end if dp[N][0] puts 'Yes' else puts 'No' end