結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
3405691582
|
| 提出日時 | 2017-03-21 09:32:54 |
| 言語 | Haskell (9.10.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 818 bytes |
| コンパイル時間 | 5,066 ms |
| コンパイル使用メモリ | 146,688 KB |
| 最終ジャッジ日時 | 2024-06-26 10:11:06 |
| 合計ジャッジ時間 | 5,426 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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:2:1: error: [GHC-87110]
Could not load module ‘Data.Map’.
It is a member of the hidden package ‘containers-0.6.8’.
Use -v to see a list of the files searched for.
|
2 | import Data.Map hiding (map,partition)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
import Prelude hiding (lookup)
import Data.Map hiding (map,partition)
import Data.Maybe (fromJust)
type Table = Map (Int,Int) Bool
main = do
n <- read <$> getLine
ws <- map read . words <$> getLine
let
sumOfWs = sum ws
putStrLn $ if even sumOfWs && snd (partition empty (n,div sumOfWs 2) ws) then "possible" else "impossible"
partition :: Table -> (Int,Int) -> [Int] -> (Table,Bool)
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 lookup (n,m) table of
Just b -> (table,b)
Nothing -> (insert (n,m) result table2,result)
where
(table1,r1) = partition table (n-1,m) ws
(table2,r2) = partition table1 (n-1,m-w) ws
result = r1 || r2
3405691582