結果
問題 | No.1 道のショートカット |
ユーザー | らっしー(raccy) |
提出日時 | 2015-06-05 21:05:47 |
言語 | Haskell (9.8.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,029 bytes |
コンパイル時間 | 6,851 ms |
コンパイル使用メモリ | 174,080 KB |
実行使用メモリ | 29,728 KB |
最終ジャッジ日時 | 2024-07-08 04:06:19 |
合計ジャッジ時間 | 17,547 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,948 KB |
testcase_05 | AC | 1 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 64 ms
10,368 KB |
testcase_09 | AC | 10 ms
8,704 KB |
testcase_10 | AC | 71 ms
10,368 KB |
testcase_11 | AC | 3,111 ms
12,936 KB |
testcase_12 | AC | 3,338 ms
13,964 KB |
testcase_13 | AC | 2,047 ms
12,800 KB |
testcase_14 | AC | 4 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 5 ms
7,808 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 3 ms
6,940 KB |
testcase_19 | AC | 3 ms
6,940 KB |
testcase_20 | AC | 89 ms
8,960 KB |
testcase_21 | AC | 6 ms
7,552 KB |
testcase_22 | AC | 3 ms
6,944 KB |
testcase_23 | TLE | - |
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 ) Main.hs:65:23: warning: [GHC-63394] [-Wx-partial] In the use of ‘head’ (imported from Data.List, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 65 | | time pc > time (head filterPcs) = pcs | ^^^^ [2 of 2] Linking a.out
ソースコード
import Data.Maybe import Data.List import Data.Function import Control.Applicative 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 (\a b -> b a) [PlaceCost { place = 1, coin = c, time = 0 }] $ map applyRoute $ sortBy (compare `on` from) $ 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) 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) | placeComp == GT = applyRoute r xs | placeComp == LT = x : applyRoute r xs | remainCoin < 0 = x : applyRoute r xs | otherwise = minTimeAdd PlaceCost { place = to r, coin = remainCoin , time = tookTime } $ x : applyRoute r xs where remainCoin = coin x - cost r tookTime = time x + rtime r placeComp = from r `compare` place x minTimeAdd :: PlaceCost -> [PlaceCost] -> [PlaceCost] minTimeAdd pc pcs | null filterPcs = pc : pcs | time pc > time (head filterPcs) = pcs | otherwise = pc : dropWhile samePlaceCoin pcs where filterPcs = filter samePlaceCoin pcs samePlaceCoin a = place pc == place a && coin pc == coin a