結果

問題 No.216 FAC
ユーザー ducktailducktail
提出日時 2018-01-08 21:54:45
言語 Haskell
(9.8.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 619 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 148,556 KB
最終ジャッジ日時 2023-08-25 00:47:16
合計ジャッジ時間 1,338 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:15:32: error: [GHC-64725]
    • Data.IntMap.fold' is gone. Use Data.IntMap.foldr or Prelude.foldr.
    • In the second argument of ‘(>=)’, namely ‘IM.fold max 0 m’
      In the expression: mp >= IM.fold max 0 m
      In the expression: if mp >= IM.fold max 0 m then "YES" else "NO"
   |
15 |     loop m mp [] [] = if mp >= IM.fold max 0 m then "YES" else "NO"
   |                                ^^^^^^^

ソースコード

diff #

import Control.Applicative ((<$>), (<*>))

import Data.IntMap (IntMap)
import qualified Data.IntMap as IM

main :: IO ()
main = do
  getLine
  solve <$> getl (map read . words) <*> getl (map read . words) >>= putStrLn

solve :: [Int] -> [Int] -> String
solve xs ys = loop IM.empty 0 xs ys
  where
    loop :: IntMap Int -> Int -> [Int] -> [Int] -> String
    loop m mp [] [] = if mp >= IM.fold max 0 m then "YES" else "NO"
    loop m mp (p:ps) (n:ns) = if n == 0 then loop m (mp + p) ps ns
                              else loop (IM.insertWith (+) n p m) mp ps ns

getl :: (String -> a) -> IO a
getl f = f <$> getLine
0