結果

問題 No.39 桁の数字を入れ替え
ユーザー vain0
提出日時 2015-07-25 14:50:38
言語 Haskell
(9.10.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 502 bytes
コンパイル時間 2,090 ms
コンパイル使用メモリ 171,392 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-02 06:32:00
合計ジャッジ時間 2,848 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 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 )

Main.hs:15:1: warning: [GHC-94817] [-Wtabs]
    Tab character found here, and in 8 further locations.
    Suggested fix: Please use spaces instead.
   |
15 |         let (ma, i) = maximum $ zip ns [0..] in --右端の最大値をみつける
   | ^^^^^^^^
[2 of 2] Linking a.out

ソースコード

diff #

import qualified Data.Char as Char
import qualified Data.List as List
import Data.Array
import Data.Maybe
import Control.Applicative
import Text.Printf

substAt :: Int -> a -> [a] -> [a]
substAt _ _ [] = []
substAt 0 y (x : xs) = y : xs
substAt i y (x : xs) = x : substAt (i - 1) y xs

solve [x] = [x]
solve (n : ns) =
	let (ma, i) = maximum $ zip ns [0..] in --右端の最大値をみつける
	if n < ma then
		ma : substAt i n ns
	else
		n : solve ns

main = do
	ns <- getLine
	putStrLn $ solve ns
0