結果
問題 | No.4 おもりと天秤 |
ユーザー |
![]() |
提出日時 | 2017-03-21 09:11:29 |
言語 | Haskell (9.10.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 736 bytes |
コンパイル時間 | 11,022 ms |
コンパイル使用メモリ | 173,440 KB |
実行使用メモリ | 30,924 KB |
最終ジャッジ日時 | 2024-07-05 05:28:01 |
合計ジャッジ時間 | 12,707 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 TLE * 1 -- * 17 |
コンパイルメッセージ
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
ソースコード
importData.ArrayimportData.MaybefromJustmain = don <- read <$> getLinews <- map read . words <$> getLineletsumOfWs = sum wstable = listArray ((1,1),(n,div sumOfWs 2)) $ repeat NothingputStrLn $ if even sumOfWs && snd (partition table n (div sumOfWs 2) ws) then "possible" else "impossible"partition table n m []| m == 0 = (table,True)| otherwise = (table,False)partition table n m (w:ws)| m < 0 = (table,False)| m == 0 = (table,True)| otherwise = case table!(n,m) ofJust b -> (table,b)Nothing -> (table2//[((n,m),Just result)],result)where(table1,r1) = partition table (n-1) m ws(table2,r2) = partition table1 (n-1) (m-w) wsresult = r1 || r2