結果
問題 | No.1 道のショートカット |
ユーザー | らっしー(raccy) |
提出日時 | 2015-06-05 19:42:17 |
言語 | Haskell (9.8.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,631 bytes |
コンパイル時間 | 848 ms |
コンパイル使用メモリ | 162,400 KB |
実行使用メモリ | 13,676 KB |
最終ジャッジ日時 | 2023-09-22 12:18:33 |
合計ジャッジ時間 | 2,734 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 2 ms
6,832 KB |
testcase_03 | AC | 2 ms
6,988 KB |
testcase_04 | AC | 3 ms
6,856 KB |
testcase_05 | AC | 3 ms
6,968 KB |
testcase_06 | AC | 2 ms
7,068 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 3 ms
6,852 KB |
testcase_16 | WA | - |
testcase_17 | AC | 2 ms
6,840 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 32 ms
13,676 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | AC | 3 ms
6,768 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
ソースコード
import Data.Maybe import Data.List import Control.Applicative 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) $ foldr ((\a b -> a b) . applyRoute) [PlaceCost { place = 1, coin = c, time = 0 }] $ createRouteList s t y m -- [([PlaceCost] -> [PlaceCost])] data PlaceCost = PlaceCost { place :: Int , coin :: Int , time :: Int } deriving (Show) data Route = Route { from :: Int , to :: Int , cost :: Int , rtime :: Int } deriving (Show) createRouteList :: [Int] -> [Int] -> [Int] -> [Int] -> [Route] createRouteList = zipWith4 Route maybeMinimum :: (Ord a) => [a] -> Maybe a maybeMinimum [] = Nothing maybeMinimum x = Just $ minimum x applyRoute :: Route -> [PlaceCost] -> [PlaceCost] applyRoute _ [] = [] applyRoute r (x:xs) | from r > place x = applyRoute r xs | from r < place x = x : applyRoute r xs | remainCoin < 0 = x : applyRoute r xs | otherwise = PlaceCost { place = to r, coin = remainCoin , time = tookTime } : x : applyRoute r xs where remainCoin = coin x - cost r tookTime = time x + rtime r