結果

問題 No.490 yukiソート
ユーザー 34056915823405691582
提出日時 2017-03-24 17:23:21
言語 Haskell
(9.6.2)
結果
WA  
実行時間 -
コード長 478 bytes
コンパイル時間 2,720 ms
コンパイル使用メモリ 160,824 KB
実行使用メモリ 23,756 KB
最終ジャッジ日時 2023-09-20 05:56:02
合計ジャッジ時間 5,778 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
11,264 KB
testcase_01 AC 2 ms
7,060 KB
testcase_02 AC 3 ms
6,996 KB
testcase_03 AC 3 ms
6,936 KB
testcase_04 AC 42 ms
11,220 KB
testcase_05 AC 43 ms
11,196 KB
testcase_06 AC 42 ms
11,304 KB
testcase_07 AC 32 ms
11,308 KB
testcase_08 AC 42 ms
11,336 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 32 ms
11,276 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

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..]
0