結果
問題 | No.410 出会い |
ユーザー |
![]() |
提出日時 | 2016-08-12 22:30:01 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 642 bytes |
コンパイル時間 | 3,386 ms |
コンパイル使用メモリ | 173,568 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 10:57:06 |
合計ジャッジ時間 | 4,146 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
コンパイルメッセージ
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 Text.Printf (printf) type Point a = (a, a) manhattanDist :: Integral a => Point a -> Point a -> a manhattanDist (x1, y1) (x2, y2) = abs (x2 - x1) + abs (y2 - y1) minTime :: (Integral a, RealFloat b) => Point a -> Point a -> b minTime p1 p2 = fromIntegral (manhattanDist p1 p2) / 2.0 tuplify2 :: [a] -> (a, a) tuplify2 [x, y] = (x, y) tuplify2 _ = error "Length of the list must be two" main :: IO () main = do p1 <- tuplify2 . fmap read . words <$> getLine :: IO (Point Int) p2 <- tuplify2 . fmap read . words <$> getLine :: IO (Point Int) printf "%.10f\n" (minTime p1 p2 :: Double)