結果

問題 No.778 クリスマスツリー
ユーザー torikuminotorikumino
提出日時 2018-12-27 00:00:36
言語 Haskell
(9.8.2)
結果
AC  
実行時間 1,313 ms / 2,000 ms
コード長 250 bytes
コンパイル時間 2,380 ms
コンパイル使用メモリ 175,276 KB
実行使用メモリ 233,032 KB
最終ジャッジ日時 2023-08-04 04:44:23
合計ジャッジ時間 10,692 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,568 KB
testcase_01 AC 2 ms
7,592 KB
testcase_02 AC 2 ms
7,568 KB
testcase_03 AC 2 ms
7,604 KB
testcase_04 AC 2 ms
7,608 KB
testcase_05 AC 3 ms
7,656 KB
testcase_06 AC 1,092 ms
227,944 KB
testcase_07 AC 263 ms
32,252 KB
testcase_08 AC 1,313 ms
106,084 KB
testcase_09 AC 793 ms
68,128 KB
testcase_10 AC 794 ms
68,132 KB
testcase_11 AC 794 ms
68,176 KB
testcase_12 AC 653 ms
69,264 KB
testcase_13 AC 464 ms
69,176 KB
testcase_14 AC 1,073 ms
233,032 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Data.Set
import Data.Array
main = do
  n <- readLn
  a <- fmap read . words <$> getLine
  let g = accumArray (flip (:)) [] (0, n) $ zip a [1..]
      dfs s i = findIndex i s + sum [dfs (insert j s) j | j <- g ! i]
  print $ dfs (singleton 0) 0
0