結果

問題 No.127 門松もどき
ユーザー gigurururugigurururu
提出日時 2015-01-15 23:31:32
言語 Scala(Beta)
(3.3.1)
結果
AC  
実行時間 2,206 ms / 5,000 ms
コード長 583 bytes
コンパイル時間 10,262 ms
コンパイル使用メモリ 254,352 KB
実行使用メモリ 174,484 KB
最終ジャッジ日時 2023-09-11 07:44:27
合計ジャッジ時間 53,721 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 999 ms
62,600 KB
testcase_01 AC 990 ms
62,536 KB
testcase_02 AC 990 ms
62,664 KB
testcase_03 AC 1,065 ms
62,580 KB
testcase_04 AC 2,175 ms
174,332 KB
testcase_05 AC 1,011 ms
62,604 KB
testcase_06 AC 1,269 ms
69,628 KB
testcase_07 AC 1,054 ms
62,980 KB
testcase_08 AC 1,021 ms
62,888 KB
testcase_09 AC 1,019 ms
62,940 KB
testcase_10 AC 1,009 ms
63,084 KB
testcase_11 AC 1,121 ms
65,076 KB
testcase_12 AC 1,693 ms
115,868 KB
testcase_13 AC 1,874 ms
146,328 KB
testcase_14 AC 1,816 ms
141,952 KB
testcase_15 AC 2,088 ms
167,884 KB
testcase_16 AC 1,807 ms
138,280 KB
testcase_17 AC 1,921 ms
151,836 KB
testcase_18 AC 1,784 ms
136,800 KB
testcase_19 AC 1,553 ms
105,920 KB
testcase_20 AC 1,552 ms
108,064 KB
testcase_21 AC 1,340 ms
82,108 KB
testcase_22 AC 2,206 ms
174,484 KB
testcase_23 AC 2,193 ms
174,088 KB
testcase_24 AC 1,938 ms
157,320 KB
testcase_25 AC 2,168 ms
166,428 KB
testcase_26 AC 1,599 ms
112,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import scala.io.StdIn
object Main extends App {
    val N = StdIn.readInt()
    val A = StdIn.readLine().split(" ").map(_.toInt)
    val dpL, dpR = Array.fill(N)(Array.fill(N)(1))
    (1 until N).foreach { d =>
        (0 until N - d).foreach { l =>
            val r = l + d
            val pdpL = dpL(l)(r - 1)
            val pdpR = dpR(l + 1)(r)
            dpL(l)(r) = if (A(l) >= A(r)) pdpL else Seq(pdpL, (pdpR + 1)).max
            dpR(l)(r) = if (A(l) <= A(r)) pdpR else Seq(pdpR, (pdpL + 1)).max
        }
    }
    println(((0 until N).map(dpL(_)(N - 1)) ++ dpR(0)).max)
}
0