結果

問題 No.390 最長の数列
ユーザー pekempeypekempey
提出日時 2016-07-29 14:35:49
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 504 bytes
コンパイル時間 1,907 ms
コンパイル使用メモリ 176,384 KB
実行使用メモリ 67,840 KB
最終ジャッジ日時 2024-04-24 10:43:50
合計ジャッジ時間 6,916 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
47,964 KB
testcase_01 AC 92 ms
47,708 KB
testcase_02 AC 92 ms
47,836 KB
testcase_03 AC 91 ms
47,708 KB
testcase_04 AC 94 ms
47,712 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 94 ms
47,708 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 245 ms
46,104 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Array.IO
import Data.List

n = 10 ^ 6

main = do
    _ <- readLn :: IO Int
    a <- sort . map read . words <$> getLine :: IO [Int]
    
    dp <- newArray (0, n) 0 :: IO (IOUArray Int Int)

    forM_ a $ \i -> do
        x <- readArray dp i
        forM_ (takeWhile (\x -> x * x <= n) [i, i * 2 .. ]) $ \j -> do
            y <- readArray dp j
            writeArray dp j $ max (x + 1) y
   
    dp' <- getElems dp
    print $ maximum dp'
    
0