結果

問題 No.90 品物の並び替え
ユーザー はむ吉🐹はむ吉🐹
提出日時 2015-10-26 22:26:36
言語 Haskell
(9.8.2)
結果
AC  
実行時間 3,182 ms / 5,000 ms
コード長 439 bytes
コンパイル時間 3,214 ms
コンパイル使用メモリ 161,332 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2023-10-01 01:34:04
合計ジャッジ時間 7,966 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,392 KB
testcase_01 AC 212 ms
12,372 KB
testcase_02 AC 2 ms
7,220 KB
testcase_03 AC 22 ms
11,372 KB
testcase_04 AC 32 ms
11,300 KB
testcase_05 AC 252 ms
12,384 KB
testcase_06 AC 172 ms
12,416 KB
testcase_07 AC 12 ms
11,180 KB
testcase_08 AC 3 ms
7,240 KB
testcase_09 AC 3,182 ms
12,404 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.List (permutations, elemIndex)
import Control.Applicative ((<$>))

judge :: [Int] -> [Int] -> Int
judge is (i1 : i2 : s : _)
    | elemIndex i1 is < elemIndex i2 is = s
    | otherwise                         = 0

main :: IO ()
main = do
    [n, _] <- map read . words <$> getLine
    ts <- map (map read) . map words . lines <$> getContents
    print $ maximum $ map (\p -> sum $ map (judge p) ts) $ permutations [0 .. n - 1]
0