結果

問題 No.4 おもりと天秤
ユーザー aimyaimy
提出日時 2017-04-22 13:19:02
言語 Haskell
(9.8.2)
結果
AC  
実行時間 63 ms / 5,000 ms
コード長 405 bytes
コンパイル時間 8,555 ms
コンパイル使用メモリ 166,120 KB
実行使用メモリ 12,488 KB
最終ジャッジ日時 2023-09-08 17:24:28
合計ジャッジ時間 4,235 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,604 KB
testcase_01 AC 3 ms
7,568 KB
testcase_02 AC 3 ms
8,392 KB
testcase_03 AC 3 ms
7,816 KB
testcase_04 AC 4 ms
9,092 KB
testcase_05 AC 62 ms
12,264 KB
testcase_06 AC 3 ms
7,736 KB
testcase_07 AC 62 ms
12,308 KB
testcase_08 AC 3 ms
7,848 KB
testcase_09 AC 5 ms
9,748 KB
testcase_10 AC 63 ms
12,488 KB
testcase_11 AC 3 ms
7,652 KB
testcase_12 AC 2 ms
7,672 KB
testcase_13 AC 2 ms
7,684 KB
testcase_14 AC 3 ms
7,656 KB
testcase_15 AC 2 ms
7,668 KB
testcase_16 AC 2 ms
7,756 KB
testcase_17 AC 2 ms
7,624 KB
testcase_18 AC 32 ms
12,024 KB
testcase_19 AC 52 ms
12,140 KB
testcase_20 AC 52 ms
12,248 KB
testcase_21 AC 52 ms
12,240 KB
testcase_22 AC 52 ms
12,336 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

import qualified Data.Set as S
import Data.List
import Data.Bool

nub' = S.toList . S.fromList

main = getContents >>= putStrLn . bool "impossible" "possible" . dave . map read . tail . words

dave :: [Int] -> Bool
dave ws = let s = sum ws in if odd s then False else elem (div s 2) (dp ws)

dp wws@(w:ws) = foldl' (\acc w -> nub' (filter (<=th) ([id, (+w)] <*> acc))) [0,w] ws
 where th = div (sum wws) 2
0