結果
| 問題 |
No.231 めぐるはめぐる (1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-02-03 15:00:48 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 974 bytes |
| コンパイル時間 | 3,166 ms |
| コンパイル使用メモリ | 180,912 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-11 15:20:56 |
| 合計ジャッジ時間 | 3,740 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
コンパイルメッセージ
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 Control.Monad (replicateM)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Function (on, fix)
import Data.Char (isSpace)
main :: IO ()
main = do
n <- getl (readi B.readInt)
solve n <$> replicateM n (getl $ readil B.readInt) >>= mapM_ putStrLn
solve :: Int -> [[Int]] -> [String]
solve n = f1 . maximumBy (compare `on` snd) . zip [1..n] . map f2
where
f1 (x, y)
| 6 * y >= 3000000 = "YES" : replicate 6 (show x)
| otherwise = ["NO"]
f2 [g, d] = g - 30000 * d
getl :: (ByteString -> a) -> IO a
getl f = f <$> B.getLine
readi :: Integral a => (ByteString -> Maybe (a, ByteString)) -> ByteString -> a
readi f s = let Just (n, _) = f s in n
readil :: Integral a => (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr g
where
g s = do
(n, s') <- f s
return (n, B.dropWhile isSpace s')