結果
| 問題 |
No.1 道のショートカット
|
| ユーザー |
|
| 提出日時 | 2015-03-08 09:32:32 |
| 言語 | Haskell (9.10.1) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,004 bytes |
| コンパイル時間 | 2,183 ms |
| コンパイル使用メモリ | 192,000 KB |
| 実行使用メモリ | 820,512 KB |
| 最終ジャッジ日時 | 2024-07-08 03:50:18 |
| 合計ジャッジ時間 | 9,888 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 6 MLE * 2 -- * 32 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
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