結果

問題 No.1 道のショートカット
ユーザー myuonmyuon
提出日時 2015-03-08 09:32:32
言語 Haskell
(9.8.2)
結果
MLE  
実行時間 -
コード長 1,004 bytes
コンパイル時間 12,585 ms
コンパイル使用メモリ 181,832 KB
実行使用メモリ 817,904 KB
最終ジャッジ日時 2023-09-22 12:02:35
合計ジャッジ時間 6,266 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,256 KB
testcase_01 AC 3 ms
7,240 KB
testcase_02 AC 2 ms
7,128 KB
testcase_03 AC 2 ms
7,316 KB
testcase_04 AC 2 ms
7,232 KB
testcase_05 AC 2 ms
7,140 KB
testcase_06 AC 2 ms
7,456 KB
testcase_07 AC 2 ms
7,348 KB
testcase_08 AC 22 ms
12,600 KB
testcase_09 AC 12 ms
12,192 KB
testcase_10 AC 22 ms
13,092 KB
testcase_11 MLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.List
import Data.Ord (comparing)

solve n c arr = case sortBy (comparing snd) (solve' n c arr ! n) of
  [] -> -1
  (x : _) -> snd x

solve' n c arr = runSTArray $ do
  plans <- newListArray (1,n) $ [(c,0)] : repeat []
  forM_ [1..n-1] $ \i -> do
    forM_ (arr ! i) $ \(t,y,m) -> do
      ps <- readArray plans i
      forM_ ps $ \(y0,m0) -> do
        when (y0-y >= 0) $ do
          r <- readArray plans t
          writeArray plans t ((y0-y,m0+m):r)
  return $ plans

main = do
  n <- (read :: String -> Int) <$> getLine
  c <- (read :: String -> Int) <$> getLine
  _ <- getLine
  ss <- fmap (read :: String -> Int) . words <$> getLine
  ts <- fmap (read :: String -> Int) . words <$> getLine
  ys <- fmap (read :: String -> Int) . words <$> getLine
  ms <- fmap (read :: String -> Int) . words <$> getLine
  
  let arr = accumArray (flip (:)) [] (1,n) $ zip ss $ zip3 ts ys ms
  print $ solve n c arr
0