結果

問題 No.4 おもりと天秤
ユーザー Hirotaka Ohkubo
提出日時 2016-07-27 17:50:09
言語 Haskell
(9.10.1)
結果
TLE  
実行時間 -
コード長 377 bytes
コンパイル時間 11,501 ms
コンパイル使用メモリ 176,768 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-11-06 17:59:58
合計ジャッジ時間 18,334 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 TLE * 1 -- * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

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