結果
問題 | No.490 yukiソート |
ユーザー |
![]() |
提出日時 | 2017-03-24 17:18:43 |
言語 | Haskell (9.10.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 478 bytes |
コンパイル時間 | 4,861 ms |
コンパイル使用メモリ | 173,440 KB |
実行使用メモリ | 19,356 KB |
最終ジャッジ日時 | 2024-07-06 01:59:30 |
合計ジャッジ時間 | 9,095 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | AC * 3 WA * 11 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 $ intersperse ' ' $ concat $ 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..]