結果

問題 No.4 おもりと天秤
コンテスト
ユーザー Hirotaka Ohkubo
提出日時 2016-07-27 17:50:09
言語 Haskell
(9.14.1)
コンパイル:
ghc -rtsopts -with-rtsopts=-K1G -o a.out -O2 _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 377 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,312 ms
コンパイル使用メモリ 192,256 KB
実行使用メモリ 15,872 KB
最終ジャッジ日時 2026-05-06 22:49:07
合計ジャッジ時間 8,256 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 TLE * 1 -- * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #
raw source code

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