結果

問題 No.2424 Josouzai
ユーザー ducktail
提出日時 2023-08-20 17:32:04
言語 Haskell
(9.10.1)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 10,733 ms
コンパイル使用メモリ 180,912 KB
実行使用メモリ 24,992 KB
最終ジャッジ日時 2024-11-30 21:00:53
合計ジャッジ時間 13,113 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Control.Monad
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Char (isSpace)

main :: IO ()
main = do
  [n, k] <- f
  unwords <$> map show <$> solve k <$> f >>= putStrLn
  where
    f = readil B.readInt <$> B.getLine

solve :: Int -> [Int] -> [Int]
solve k as = [length l, k - last l]
  where
    l = takeWhile (<= k) $ scanl1 (+) $ sort as

readil :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr $ f . B.dropWhile isSpace
0