結果
問題 | No.4 おもりと天秤 |
ユーザー | 3405691582 |
提出日時 | 2017-03-21 09:28:17 |
言語 | Haskell (9.8.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 810 bytes |
コンパイル時間 | 2,851 ms |
コンパイル使用メモリ | 162,224 KB |
実行使用メモリ | 16,212 KB |
最終ジャッジ日時 | 2023-09-18 14:40:26 |
合計ジャッジ時間 | 7,971 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
7,196 KB |
testcase_01 | AC | 3 ms
7,264 KB |
testcase_02 | AC | 12 ms
11,336 KB |
testcase_03 | AC | 3 ms
7,340 KB |
testcase_04 | AC | 3 ms
7,472 KB |
testcase_05 | TLE | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
コンパイルメッセージ
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
ソースコード
import Prelude hiding (lookup) import Data.Map hiding (map,partition) import Data.Maybe (fromJust) 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 :: Map (Int,Int) Bool -> Int -> Int -> [Int] -> (Map (Int,Int) Bool,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 table,result) where (table1,r1) = partition table (n-1) m ws (table2,r2) = partition table1 (n-1) (m-w) ws result = r1 || r2