結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
karrym_
|
| 提出日時 | 2015-06-04 21:38:36 |
| 言語 | Haskell (9.10.1) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,061 bytes |
| コンパイル時間 | 9,427 ms |
| コンパイル使用メモリ | 171,392 KB |
| 実行使用メモリ | 820,512 KB |
| 最終ジャッジ日時 | 2024-07-08 04:03:03 |
| 合計ジャッジ時間 | 16,742 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 4 MLE * 1 -- * 35 |
コンパイルメッセージ
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 Control.Arrow
main :: IO ()
main = do
n <- read <$> getLine
c <- read <$> getLine
getLine
ss <- map read . words <$> getLine
ts <- map read . words <$> getLine
ys <- map read . words <$> getLine
ms <- map read . words <$> getLine
print $ fromMaybe (-1) $ solve n c ss ts ys ms
solve :: Int -> Int -> [Int] -> [Int] -> [Int] -> [Int] -> Maybe Int
solve n c ss ts ys ms = foldr search Nothing $ makeRoad n ss ts ys ms where
search :: (Int, Int) -> Maybe Int -> Maybe Int
search (y, m) Nothing = if y <= c then Just m else Nothing
search (y, m) (Just t) = if y <= c && m < t then Just m else Just t
makeRoad :: Int -> [Int] -> [Int] -> [Int] -> [Int] -> [(Int, Int)]
makeRoad n ss ts ys ms = do
to <- elemIndices n ts
let from = ss !! to
money = ys !! to
time = ms !! to
if from == 1
then return (money, time)
else ((+ money) *** (+ time)) <$> makeRoad from ss ts ys ms
karrym_