結果

問題 No.90 品物の並び替え
ユーザー はむ吉🐹はむ吉🐹
提出日時 2015-10-26 22:59:47
言語 Haskell
(9.8.2)
結果
AC  
実行時間 962 ms / 5,000 ms
コード長 696 bytes
コンパイル時間 10,591 ms
コンパイル使用メモリ 200,892 KB
実行使用メモリ 13,704 KB
最終ジャッジ日時 2023-10-11 04:08:24
合計ジャッジ時間 6,675 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,724 KB
testcase_01 AC 83 ms
12,604 KB
testcase_02 AC 3 ms
7,712 KB
testcase_03 AC 12 ms
11,852 KB
testcase_04 AC 22 ms
11,984 KB
testcase_05 AC 92 ms
12,584 KB
testcase_06 AC 62 ms
12,596 KB
testcase_07 AC 4 ms
8,712 KB
testcase_08 AC 2 ms
7,752 KB
testcase_09 AC 962 ms
13,704 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)
import Control.Applicative ((<$>))
import Data.Maybe (fromJust)
import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Lazy.Char8 as B

judge :: V.Vector Int -> V.Vector Int -> Int
judge is t
    | V.elemIndex i1 is < V.elemIndex i2 is = s
    | otherwise                             = 0
    where
        i1 = (V.!) t 0
        i2 = (V.!) t 1
        s = (V.!) t 2

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