結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー universatouniversato
提出日時 2020-05-29 22:38:17
言語 Ruby
(3.3.0)
結果
MLE  
実行時間 -
コード長 369 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 643,840 KB
最終ジャッジ日時 2024-04-23 23:55:16
合計ジャッジ時間 4,850 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
17,664 KB
testcase_01 AC 84 ms
12,160 KB
testcase_02 AC 84 ms
12,160 KB
testcase_03 AC 84 ms
12,288 KB
testcase_04 AC 84 ms
12,160 KB
testcase_05 AC 83 ms
12,160 KB
testcase_06 AC 83 ms
12,288 KB
testcase_07 AC 83 ms
12,160 KB
testcase_08 MLE -
testcase_09 -- -
testcase_10 -- -
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_cur * (t - 1)
    dp[i+1][j+1] += dp_cur
  end
end

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

puts b
0