結果

問題 No.4 おもりと天秤
ユーザー Hirotaka OhkuboHirotaka Ohkubo
提出日時 2016-07-27 17:50:09
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 377 bytes
コンパイル時間 6,410 ms
コンパイル使用メモリ 164,788 KB
実行使用メモリ 7,632 KB
最終ジャッジ日時 2023-08-06 14:54:48
合計ジャッジ時間 13,665 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,120 KB
testcase_01 AC 2 ms
7,100 KB
testcase_02 AC 4 ms
7,444 KB
testcase_03 AC 2 ms
7,168 KB
testcase_04 AC 3 ms
7,268 KB
testcase_05 AC 3 ms
7,604 KB
testcase_06 AC 3 ms
7,100 KB
testcase_07 AC 3 ms
7,576 KB
testcase_08 AC 3 ms
7,428 KB
testcase_09 AC 3 ms
7,572 KB
testcase_10 AC 3 ms
7,632 KB
testcase_11 AC 2 ms
7,164 KB
testcase_12 AC 2 ms
7,148 KB
testcase_13 AC 2 ms
7,148 KB
testcase_14 AC 3 ms
7,264 KB
testcase_15 AC 3 ms
7,172 KB
testcase_16 AC 2 ms
7,204 KB
testcase_17 AC 2 ms
7,136 KB
testcase_18 TLE -
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

ソースコード

diff #

import Data.List

main = do
  getLine
  l <- getLine
  let ws = map read $ words l
  let r = compute ws
  putStrLn $ if r then "possible" else "impossible"

compute ws = even total && make (div total 2) ws where 
  total = sum ws

make 0 _ = True
make n [] = False
make n (w:ws)
  | n < 0 = False
  | n == w = True
  | n < w  = make n ws
  | True   = make (n-w) ws || make n ws
0