結果
問題 |
No.1948 足し算するだけのパズルゲーム(1)
|
ユーザー |
![]() |
提出日時 | 2024-08-31 09:00:20 |
言語 | Scala(Beta) (3.6.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,081 bytes |
コンパイル時間 | 15,481 ms |
コンパイル使用メモリ | 265,768 KB |
実行使用メモリ | 70,632 KB |
最終ジャッジ日時 | 2024-08-31 09:01:11 |
合計ジャッジ時間 | 45,425 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 WA * 5 |
ソースコード
import scala.io.StdIn.readLine @main def main(): Unit = val hw = readLine.split(" ").map(_.toInt) val (h, w) = (hw(0), hw(1)) val dp: Array[Array[Array[Int]]] = Array.ofDim[Int](2, 500, 500) val input: Array[Array[Int]] = Array.ofDim[Int](500, 500) for i <- 0 until h do input(i) = readLine().split(" ").map(_.toInt) dp(0)(0)(0) = input(0)(0) for f <- 0 until 2 y <- 0 until h x <- 0 until w do if y < h - 1 then if dp(f)(y)(x) > input(y + 1)(x) && dp(f)(y + 1)(x) < dp(f)(y)(x) + input(y + 1)(x) then dp(f)(y + 1)(x) = dp(f)(y)(x) + input(y + 1)(x) if f == 0 && dp(1)(y + 1)(x) < dp(0)(y)(x) then dp(1)(y + 1)(x) = dp(0)(y)(x) if x < w - 1 then if dp(f)(y)(x) > input(y)(x + 1) && dp(f)(y)(x + 1) < dp(f)(y)(x) + input(y)(x + 1) then dp(f)(y)(x + 1) = dp(f)(y)(x) + input(y)(x + 1) if f == 0 && dp(1)(y)(x + 1) < dp(0)(y)(x) then dp(1)(y)(x + 1) = dp(0)(y)(x) val ans = if (dp(0)(h - 1)(w - 1) + dp(1)(h - 1)(w - 1)) > input(h - 1)(w - 1) then "Yes" else "No" println(ans)