結果
問題 | No.127 門松もどき |
ユーザー | tottoripaper |
提出日時 | 2015-05-09 22:27:35 |
言語 | Haskell (9.8.2) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,486 bytes |
コンパイル時間 | 10,663 ms |
コンパイル使用メモリ | 208,768 KB |
実行使用メモリ | 288,032 KB |
最終ジャッジ日時 | 2024-07-05 21:19:38 |
合計ジャッジ時間 | 25,184 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 111 ms
144,640 KB |
testcase_01 | AC | 111 ms
144,768 KB |
testcase_02 | AC | 112 ms
144,640 KB |
testcase_03 | AC | 110 ms
144,768 KB |
testcase_04 | AC | 1,049 ms
260,224 KB |
testcase_05 | RE | - |
testcase_06 | AC | 180 ms
160,128 KB |
testcase_07 | AC | 112 ms
145,008 KB |
testcase_08 | AC | 107 ms
144,880 KB |
testcase_09 | AC | 107 ms
144,768 KB |
testcase_10 | AC | 107 ms
144,640 KB |
testcase_11 | AC | 110 ms
145,792 KB |
testcase_12 | AC | 597 ms
220,928 KB |
testcase_13 | AC | 780 ms
244,864 KB |
testcase_14 | AC | 709 ms
234,752 KB |
testcase_15 | AC | 961 ms
268,828 KB |
testcase_16 | AC | 703 ms
235,008 KB |
testcase_17 | AC | 786 ms
252,052 KB |
testcase_18 | AC | 679 ms
235,392 KB |
testcase_19 | AC | 452 ms
202,240 KB |
testcase_20 | AC | 466 ms
205,068 KB |
testcase_21 | AC | 266 ms
174,336 KB |
testcase_22 | AC | 1,081 ms
275,840 KB |
testcase_23 | AC | 1,078 ms
288,032 KB |
testcase_24 | AC | 789 ms
234,752 KB |
testcase_25 | AC | 948 ms
250,148 KB |
testcase_26 | AC | 507 ms
201,856 KB |
コンパイルメッセージ
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
ソースコード
-- [元のコード] http://yukicoder.me/submissions/15723 import Control.Monad import qualified Data.Vector as V import qualified Data.Vector.Unboxed.Mutable as MV import qualified Data.ByteString.Char8 as B import Data.Maybe (fromJust) import Debug.Trace readInts :: B.ByteString -> [Int] readInts = map (fst . fromJust . B.readInt) . B.words getInts :: IO [Int] getInts = liftM readInts B.getLine main = do n <- readLn as <- liftM V.fromList getInts dp <- MV.replicate (2*3000*3000) (-1 :: Int) let at l r p = l + 3000 * (r + 3000 * p) f :: Int -> Int -> Int -> IO Int f l r p | l == r = return 0 | otherwise = do v <- MV.read dp (at l r p) if v /= (-1) then return v else g l r p g :: Int -> Int -> Int -> IO Int g l r p | p == 0 = do v <- f l (r-1) p v' <- if as V.! l < as V.! r then liftM (+1) (f (l+1) r (1-p)) else return 0 let res = max v v' MV.write dp (at l r p) res return res | otherwise = do v <- f (l+1) r p v' <- if as V.! r < as V.! l then liftM (+1) (f l (r-1) (1-p)) else return 0 let res = max v v' MV.write dp (at l r p) res return res xs = liftM concat $ forM [0..n-1] $ \i -> forM [i+1..n-1] $ \j -> liftM2 (((+1).) . max) (f i j 0) (f i j 1) in print =<< liftM maximum xs