結果
問題 | No.490 yukiソート |
ユーザー |
![]() |
提出日時 | 2017-03-24 17:23:21 |
言語 | Haskell (9.10.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 478 bytes |
コンパイル時間 | 2,048 ms |
コンパイル使用メモリ | 174,208 KB |
実行使用メモリ | 19,232 KB |
最終ジャッジ日時 | 2024-07-06 01:59:54 |
合計ジャッジ時間 | 6,377 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | AC * 10 WA * 4 TLE * 1 -- * 19 |
コンパイルメッセージ
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
ソースコード
import Data.Array import Data.List main = do n <- read <$> getLine as <- map read . words <$> getLine putStrLn $ concat $ intersperse " " $ map show $ elems $ yukiSort n as yukiSort :: Int -> [Int] -> Array Int Int yukiSort n as = yS (listArray (0,n-1) as) [1..2*n-3] where yS aa [] = aa yS aa (i:is) = yS (foldl (\a p->if a!p>a!(i-p) then a//[(p,a!(i-p)),(i-p,a!p)] else a) aa ps) is where ps = takeWhile ((i>).(*2)) $ dropWhile ((n-1<=).(i-)) [0..]