結果
| 問題 | 
                            No.90 品物の並び替え
                             | 
                    
| コンテスト | |
| ユーザー | 
                             くれちー
                         | 
                    
| 提出日時 | 2017-04-15 11:22:11 | 
| 言語 | Haskell  (9.10.1)  | 
                    
| 結果 | 
                             
                                CE
                                 
                             
                            
                            (最新)
                                AC
                                 
                             
                            (最初)
                            
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 744 bytes | 
| コンパイル時間 | 236 ms | 
| コンパイル使用メモリ | 147,584 KB | 
| 最終ジャッジ日時 | 2024-11-14 19:59:50 | 
| 合計ジャッジ時間 | 636 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
            
            
            
            
            ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
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:20:31: error: [GHC-58481]
    parse error on input ‘<-’
    Suggested fix: Possibly caused by a missing 'do'?
   |
20 |         [item1, item2, score] <- map read . words <$> table
   |                               ^^
            
            ソースコード
import Control.Monad (replicateM)
import Data.List (elemIndex, permutations)
solve :: Integral a => a -> [(a, a, a)] -> a
solve n table = maximum $ do
    items <- permutations [0..n - 1]
    return $ calc items table where
        calc :: Integral a => [a] -> [(a, a, a)] -> a
        calc items' table' = sum $ do
            (item1, item2, score) <- table'
            return $ case (compare <$> elemIndex item1 <*> elemIndex item2) items' of
                LT -> score
                GT -> 0
main :: IO ()
main = do
    [n, m] <- map read . words <$> getLine
    table <- replicateM m getLine
    let table' = do
        [item1, item2, score] <- map read . words <$> table
        return (item1, item2, score)
    print $ solve n table'
            
            
            
        
            
くれちー