結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー universatouniversato
提出日時 2020-05-29 22:41:35
言語 Ruby
(3.3.0)
結果
MLE  
実行時間 -
コード長 426 bytes
コンパイル時間 69 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 288,896 KB
最終ジャッジ日時 2024-04-24 00:06:04
合計ジャッジ時間 6,104 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
17,408 KB
testcase_01 AC 84 ms
12,288 KB
testcase_02 AC 79 ms
12,160 KB
testcase_03 AC 77 ms
12,288 KB
testcase_04 AC 77 ms
12,160 KB
testcase_05 AC 78 ms
12,160 KB
testcase_06 AC 77 ms
12,160 KB
testcase_07 AC 75 ms
12,288 KB
testcase_08 AC 1,708 ms
114,048 KB
testcase_09 AC 75 ms
12,160 KB
testcase_10 MLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - q
Syntax OK

ソースコード

diff #

mod = 998244353

n, q = gets.to_s.split.map{|t| t.to_i }
a    = gets.to_s.split.map{|t| t.to_i }
b    = gets.to_s.split.map{|t| t.to_i }

dp = Array.new(n+1){ [0] * (n+2) }
dp[0][0] = 1

a.each_with_index do |t, i|
  
  i.downto(0) do |j|
    dp_cur = dp[i][j]
    dp[i+1][j] = ( dp[i+1][j] + dp_cur * (t - 1) ) % mod
    dp[i+1][j+1] = ( dp[i+1][j+1] + dp_cur ) % mod
  end
end

b.map!{|t| dp[n][t] % mod }

puts b.join("\n")
0