結果

問題 No.306 さいたま2008
ユーザー aimyaimy
提出日時 2017-06-14 22:22:19
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 661 bytes
コンパイル時間 8,242 ms
コンパイル使用メモリ 164,920 KB
実行使用メモリ 5,492 KB
最終ジャッジ日時 2023-10-25 03:58:43
合計ジャッジ時間 9,811 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,384 KB
testcase_01 AC 3 ms
5,388 KB
testcase_02 AC 3 ms
5,384 KB
testcase_03 AC 3 ms
5,388 KB
testcase_04 AC 2 ms
5,388 KB
testcase_05 AC 3 ms
5,388 KB
testcase_06 AC 2 ms
5,388 KB
testcase_07 AC 2 ms
5,388 KB
testcase_08 AC 3 ms
5,388 KB
testcase_09 AC 3 ms
5,388 KB
testcase_10 AC 2 ms
5,388 KB
testcase_11 AC 2 ms
5,388 KB
testcase_12 AC 3 ms
5,388 KB
testcase_13 AC 2 ms
5,384 KB
testcase_14 AC 3 ms
5,384 KB
testcase_15 AC 2 ms
5,388 KB
testcase_16 AC 2 ms
5,388 KB
testcase_17 AC 3 ms
5,388 KB
testcase_18 AC 2 ms
5,384 KB
testcase_19 AC 2 ms
5,388 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 3 ms
5,388 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Data.Ratio
import Text.Printf
import Data.Fixed

apply n f x = foldr ($) x (replicate n f)

main = do
 [xa,ya] <- map read . words <$> getLine :: IO [Double]
 [xb,yb] <- map read . words <$> getLine :: IO [Double]
 print (saitama xa ya xb yb) 

saitama xa ya xb yb
 | ya > yb = snd $ apply 100 (triSearch (euc xa ya xb yb)) (ya,yb)
 | otherwise = snd $ apply 100 (triSearch (euc xb yb xa ya)) (yb,ya)

triSearch f (lo,hi)
 | f md1 < f md2 = (lo,md2) 
 | otherwise = (md1,hi)
 where
  md1 = lo + (hi-lo)/3
  md2 = lo + (2*(hi-lo))/3

euc xa ya xb yb yp = dist (0,yp) (xa,ya) + dist (0,yp) (xb,yb)
 where dist (p1,q1) (p2,q2) = sqrt $ (p1-p2)^2 + (q1-q2)^2
0