結果
問題 | No.10 +か×か |
ユーザー | okaduki |
提出日時 | 2017-05-20 03:55:08 |
言語 | Haskell (9.8.2) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,052 bytes |
コンパイル時間 | 11,737 ms |
コンパイル使用メモリ | 192,000 KB |
実行使用メモリ | 813,312 KB |
最終ジャッジ日時 | 2024-09-18 23:10:29 |
合計ジャッジ時間 | 19,288 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,812 KB |
testcase_02 | AC | 1 ms
6,812 KB |
testcase_03 | MLE | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_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 ) Main.hs:29:17: warning: [GHC-63394] [-Wx-partial] In the use of ‘tail’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 29 | putStrLn $ f (tail xs) tot (memo // [(head xs, "")]) | ^^^^ Main.hs:29:41: warning: [GHC-63394] [-Wx-partial] In the use of ‘head’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 29 | putStrLn $ f (tail xs) tot (memo // [(head xs, "")]) | ^^^^ [2 of 2] Linking a.out
ソースコード
{-# LANGUAGE FlexibleContexts, OverloadedStrings #-} import Control.Applicative import Control.Monad import qualified Data.ByteString.Char8 as B import Data.Maybe (fromJust) import Text.Printf import Debug.Trace import Data.Array.IArray getInts :: IO [Int] getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine imap :: (IArray a e, Ix i, Enum i) => (i,i) -> (i -> i) -> a i e -> e -> a i e imap (a,b) f arr e = listArray (a,b) (repeat e) // [(i', arr!i) | i <- [a..b], let i' = f i, a <= i', i' <= b] f [] tot memo = memo!tot f (x:xs) tot memo = f xs tot memo' where memo_plus = amap (\e -> e ++ "+") $ imap (0, tot) (\i -> i+x) memo "%" memo_prod = amap (\e -> e ++ "*") $ imap (0, tot) (\i -> i*x) memo "%" memo' = array (0,tot) $ zipWith (\(i1,x1) (_,x2) -> (i1, max x1 x2)) (assocs memo_plus) (assocs memo_prod) main = do [n] <- getInts [tot] <- getInts xs <- getInts let memo = listArray (0,tot) (repeat "%") :: Array Int String putStrLn $ f (tail xs) tot (memo // [(head xs, "")])