結果
| 問題 | No.91 赤、緑、青の石 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-01 21:58:37 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 579 bytes |
| 記録 | |
| コンパイル時間 | 9,342 ms |
| コンパイル使用メモリ | 176,256 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-07 12:29:12 |
| 合計ジャッジ時間 | 5,235 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.10.1/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
-- 解説を参照
import Data.List
rInt :: String -> Int
rInt = read
binarySearch :: [Int] -> Int -> Int -> Int
binarySearch rgb low high
| high - low == 1 = low
| check = binarySearch rgb mid high
| otherwise = binarySearch rgb low mid
where
mid = (low + high) `div` 2
check = (foldr chengeNum 0 (map (\x -> x - mid) rgb)) >= 0
chengeNum x y
| x > 0 = x `div` 2 + y
| otherwise = x + y
main = do
stones <- map rInt . words <$> getLine
print $ binarySearch stones 0 (2^24)