結果
問題 | No.10 +か×か |
ユーザー | okaduki |
提出日時 | 2017-05-20 04:49:43 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 2,355 ms / 5,000 ms |
コード長 | 1,155 bytes |
コンパイル時間 | 5,124 ms |
コンパイル使用メモリ | 180,556 KB |
実行使用メモリ | 177,440 KB |
最終ジャッジ日時 | 2023-08-21 06:22:12 |
合計ジャッジ時間 | 13,999 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
7,236 KB |
testcase_01 | AC | 3 ms
7,140 KB |
testcase_02 | AC | 3 ms
7,204 KB |
testcase_03 | AC | 2,323 ms
176,432 KB |
testcase_04 | AC | 1,513 ms
66,860 KB |
testcase_05 | AC | 2 ms
7,252 KB |
testcase_06 | AC | 2,355 ms
177,440 KB |
testcase_07 | AC | 1,612 ms
63,780 KB |
testcase_08 | AC | 333 ms
53,580 KB |
testcase_09 | AC | 754 ms
93,404 KB |
testcase_10 | AC | 12 ms
12,400 KB |
testcase_11 | AC | 3 ms
8,012 KB |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [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 import Data.Array.ST getInts :: IO [Int] getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine g tot xs = runSTArray $ do arr <- newArray (0,tot) "%" writeArray arr (head xs) "" foldM (\a x -> do a' <- newArray (0,tot) "%" plused <- forM [i | i <- [0..tot], i+x <= tot] (\i -> readArray a i >>= \s -> return (i+x, B.append s "+")) forM_ plused (\(i,x) -> writeArray a' i x) multied <- forM [i | i <- [0..tot], i*x <= tot] (\i -> readArray a i >>= \s -> return (i*x, B.append s "*")) forM_ multied $ \(i,x) -> do px <- readArray a' i if x > px then writeArray a' i x else return () return a' ) arr (tail xs) solve tot xs = (g tot xs)!tot main = do [n] <- getInts [tot] <- getInts xs <- getInts B.putStrLn $ solve tot xs