結果
問題 | No.1 道のショートカット |
ユーザー | らっしー(raccy) |
提出日時 | 2015-06-04 21:39:17 |
言語 | Haskell (9.8.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,505 bytes |
コンパイル時間 | 9,020 ms |
コンパイル使用メモリ | 171,520 KB |
実行使用メモリ | 14,208 KB |
最終ジャッジ日時 | 2024-07-08 04:03:37 |
合計ジャッジ時間 | 15,936 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | TLE | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
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.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import Data.Maybe import Data.List -- import Debug.Trace main :: IO () main = do n <- read <$> getLine c <- read <$> getLine v <- read <$> getLine s <- map read . words <$> getLine t <- map read . words <$> getLine y <- map read . words <$> getLine m <- map read . words <$> getLine print $ no1 n c v s t y m no1 :: Int -> Int -> Int -> [Int] -> [Int] -> [Int] -> [Int] -> Int no1 n c v s t y m = fromMaybe (-1) $ no1' n c v s t y m no1' :: Int -> Int -> Int -> [Int] -> [Int] -> [Int] -> [Int] -> Maybe Int no1' n c _ s t y m = maybeMinimum $ map time $ filter (\a -> place a == n) $ foldl' (>>=) [PlaceCost { place = 1, coin = c, time = 0 }] $ replicate n (`fromTo` createRouteList s t y m) data PlaceCost = PlaceCost { place :: Int, coin :: Int, time :: Int} deriving (Show) data Route = Route { from :: Int, to :: Int, cost :: Int, rtime :: Int} deriving (Show) fromTo :: PlaceCost -> [Route] -> [PlaceCost] fromTo pc [] = [pc] fromTo pc (r:rs) | place pc /= from r = fromTo pc rs | remainCoin < 0 = fromTo pc rs | otherwise = PlaceCost { place = to r, coin = remainCoin, time = tookTime } : fromTo pc rs where remainCoin = coin pc - cost r tookTime = time pc + rtime r createRouteList :: [Int] -> [Int] -> [Int] -> [Int] -> [Route] createRouteList = zipWith4 (\s t y m -> Route { from = s , to = t, cost = y, rtime = m }) maybeMinimum :: (Ord a) => [a] -> Maybe a maybeMinimum [] = Nothing maybeMinimum x = Just $ minimum x