結果

問題 No.778 クリスマスツリー
ユーザー torikuminotorikumino
提出日時 2018-12-27 07:30:48
言語 Haskell
(9.6.2)
結果
AC  
実行時間 1,402 ms / 2,000 ms
コード長 315 bytes
コンパイル時間 11,120 ms
コンパイル使用メモリ 165,104 KB
実行使用メモリ 234,024 KB
最終ジャッジ日時 2023-08-04 04:46:00
合計ジャッジ時間 9,282 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,340 KB
testcase_01 AC 2 ms
7,272 KB
testcase_02 AC 2 ms
7,344 KB
testcase_03 AC 3 ms
7,352 KB
testcase_04 AC 2 ms
7,404 KB
testcase_05 AC 3 ms
7,460 KB
testcase_06 AC 1,082 ms
228,808 KB
testcase_07 AC 272 ms
32,128 KB
testcase_08 AC 1,402 ms
113,116 KB
testcase_09 AC 864 ms
68,048 KB
testcase_10 AC 854 ms
67,968 KB
testcase_11 AC 853 ms
67,948 KB
testcase_12 AC 684 ms
69,148 KB
testcase_13 AC 464 ms
69,100 KB
testcase_14 AC 1,101 ms
234,024 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 qualified Data.Set as S
import Data.Array
import Data.List
main = do
  n <- readLn
  a <- map read . words <$> getLine :: IO [Int]
  let g = accumArray (flip (:)) [] (0, n) $ zip a [1..]
      dfs s i x = foldl' (\y j -> dfs (S.insert j s) j y) (S.findIndex i s + x) (g ! i)
  print $ dfs (S.singleton 0) 0 0
0