結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
|
| 提出日時 | 2025-08-13 23:13:45 |
| 言語 | Standard ML (MLton 20210117) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 797 bytes |
| コンパイル時間 | 4,934 ms |
| コンパイル使用メモリ | 686,720 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-08-13 23:13:52 |
| 合計ジャッジ時間 | 5,181 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
fun readInt () =
valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn)
val () =
let
val n = readInt ()
val vs = Array.tabulate (n, fn _ => readInt ())
val dp = Array.array (n + 1, 0)
fun doDp index =
if index <= n
then
(
Array.update (dp, index, Int.max (Array.sub (dp, index - 1), Array.sub (dp, index - 2) + Array.sub (vs, index - 1)));
doDp (index + 1)
)
else ignore ()
in
if n = 1 then print (Int.toString (Array.sub (vs, 0)) ^ "\n")
else
(
Array.update (dp, 1, Array.sub (vs, 0));
doDp 2;
print (Int.toString (Array.sub (dp, n)) ^ "\n")
)
end