結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2017-06-11 22:03:14
言語 Haskell
(9.8.2)
結果
AC  
実行時間 113 ms / 5,000 ms
コード長 943 bytes
コンパイル時間 5,905 ms
コンパイル使用メモリ 225,328 KB
実行使用メモリ 21,760 KB
最終ジャッジ日時 2024-04-25 23:55:21
合計ジャッジ時間 9,449 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
21,760 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 41 ms
12,288 KB
testcase_03 AC 89 ms
20,352 KB
testcase_04 AC 98 ms
19,864 KB
testcase_05 AC 98 ms
19,612 KB
testcase_06 AC 95 ms
20,248 KB
testcase_07 AC 108 ms
19,200 KB
testcase_08 AC 113 ms
19,200 KB
testcase_09 AC 96 ms
19,328 KB
testcase_10 AC 89 ms
19,592 KB
testcase_11 AC 95 ms
19,600 KB
testcase_12 AC 86 ms
19,760 KB
testcase_13 AC 99 ms
20,200 KB
testcase_14 AC 106 ms
19,200 KB
testcase_15 AC 87 ms
20,808 KB
testcase_16 AC 82 ms
19,616 KB
testcase_17 AC 79 ms
19,736 KB
testcase_18 AC 77 ms
19,740 KB
testcase_19 AC 87 ms
19,328 KB
testcase_20 AC 88 ms
19,200 KB
testcase_21 AC 88 ms
19,328 KB
testcase_22 AC 71 ms
19,720 KB
testcase_23 AC 75 ms
19,868 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 5 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 24 ms
10,240 KB
testcase_29 AC 14 ms
8,960 KB
testcase_30 AC 5 ms
6,948 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 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 [Int]
    k <- unsafeReadDec <$> T.getLine :: IO Int
    printf "%.16f\n" (computeMax ls k :: Double)
0