結果
問題 |
No.90 品物の並び替え
|
ユーザー |
![]() |
提出日時 | 2016-07-28 15:17:34 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 148 ms / 5,000 ms |
コード長 | 562 bytes |
コンパイル時間 | 8,801 ms |
コンパイル使用メモリ | 174,080 KB |
実行使用メモリ | 9,728 KB |
最終ジャッジ日時 | 2024-11-06 18:09:32 |
合計ジャッジ時間 | 6,269 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import Data.Array import Data.List import Control.Monad main = do li <- getLine let (n:m:_) = map read $ words li cs <- forM [1..m] $ \_ -> do li <- getLine let (i1:i2:s:_) = map read $ words li return ((seq i1 i1,seq i2 i2),seq s s) print $ compute n cs compute :: Int -> [((Int,Int),Int)] -> Int compute n cs = maximum $ step [0..n-1] where ar = accumArray (+) 0 ((0,0),(n-1,n-1)) cs step [] = [ 0 ] step xs = [ s0 + s1 | x <- xs , let xs1 = delete x xs , let s0 = sum [ ar ! (x,y) | y <- xs1 ] , s1 <- step xs1 ]