結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-06-11 12:49:31
言語 Haskell
(9.8.2)
結果
AC  
実行時間 111 ms / 5,000 ms
コード長 971 bytes
コンパイル時間 11,315 ms
コンパイル使用メモリ 225,328 KB
実行使用メモリ 22,412 KB
最終ジャッジ日時 2024-04-25 23:44:18
合計ジャッジ時間 14,868 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
22,412 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 42 ms
12,416 KB
testcase_03 AC 85 ms
20,648 KB
testcase_04 AC 98 ms
21,148 KB
testcase_05 AC 99 ms
21,156 KB
testcase_06 AC 96 ms
21,272 KB
testcase_07 AC 111 ms
19,328 KB
testcase_08 AC 109 ms
19,200 KB
testcase_09 AC 99 ms
19,072 KB
testcase_10 AC 93 ms
21,520 KB
testcase_11 AC 99 ms
21,264 KB
testcase_12 AC 88 ms
21,168 KB
testcase_13 AC 98 ms
20,328 KB
testcase_14 AC 106 ms
19,200 KB
testcase_15 AC 86 ms
20,556 KB
testcase_16 AC 83 ms
21,404 KB
testcase_17 AC 82 ms
21,272 KB
testcase_18 AC 79 ms
21,148 KB
testcase_19 AC 87 ms
19,072 KB
testcase_20 AC 87 ms
19,200 KB
testcase_21 AC 86 ms
19,072 KB
testcase_22 AC 75 ms
21,384 KB
testcase_23 AC 79 ms
21,404 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 5 ms
6,944 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 24 ms
10,112 KB
testcase_29 AC 14 ms
8,832 KB
testcase_30 AC 5 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

import Control.Applicative ((<$>))
import Data.Int (Int64)
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Text.Printf (printf)

unsafeReadDec:: Integral a => T.Text -> a
unsafeReadDec t = case T.decimal t of
    Right x -> fst x
    Left e -> error e

computeMax :: (Integral a, RealFloat b) => [a] -> a -> b
computeMax ls k = bis eps maxLength
    where
        eps = 10.0 ** (-9)
        maxLength = 10.0 ** 9
        bis low high
            | high - low <= eps || (high - low) / low <= eps = mid
            | n >= k = bis mid high
            | otherwise = bis low mid
            where
                mid = (high + low) / 2
                n = sum $ fmap (floor . (/ mid) . fromIntegral) ls

main :: IO ()
main = do
    _ <- T.getLine
    ls <- fmap unsafeReadDec . T.words <$> T.getLine :: IO [Int64]
    k <- unsafeReadDec <$> T.getLine :: IO Int64
    printf "%.16f\n" (computeMax ls k :: Double)
0