結果

問題 No.490 yukiソート
ユーザー LeonardoneLeonardone
提出日時 2017-03-13 00:39:20
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 527 bytes
コンパイル時間 1,973 ms
コンパイル使用メモリ 164,860 KB
実行使用メモリ 37,396 KB
最終ジャッジ日時 2023-09-12 12:12:27
合計ジャッジ時間 8,458 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
11,440 KB
testcase_01 AC 2 ms
6,976 KB
testcase_02 AC 3 ms
7,156 KB
testcase_03 AC 2 ms
7,176 KB
testcase_04 AC 372 ms
15,648 KB
testcase_05 AC 372 ms
15,660 KB
testcase_06 AC 372 ms
15,704 KB
testcase_07 AC 373 ms
15,652 KB
testcase_08 AC 372 ms
15,676 KB
testcase_09 AC 372 ms
15,652 KB
testcase_10 AC 372 ms
15,688 KB
testcase_11 AC 373 ms
16,452 KB
testcase_12 AC 371 ms
15,924 KB
testcase_13 AC 373 ms
15,708 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 #

-- yukicoder My practice
-- author: Leonardone @ NEETSDKASU

main = getContents >>= putStrLn . unwords . map show . solve . map read . words

solve (n:xs) = baz n xs

baz n xs = foldr (bar n) xs $ reverse [1 .. 2 * n - 4]

bar n i xs = foldr (\k xs -> foo k (i - k) xs) xs . reverse
           $ [k | k <- [0 .. i], k < i - k, k < n, i - k < n]
        
foo p q as = bs where
    (xs2, (aq:xs1)) = splitAt q as
    (xs4, (ap:xs3)) = splitAt p xs2
    bp = min ap aq
    bq = max ap aq
    bs = xs4 ++ [bp] ++ xs3 ++ [bq] ++ xs1
0