結果

問題 No.4 おもりと天秤
ユーザー Hirotaka OhkuboHirotaka Ohkubo
提出日時 2016-07-27 19:40:46
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 486 bytes
コンパイル時間 8,752 ms
コンパイル使用メモリ 172,032 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-24 10:25:53
合計ジャッジ時間 2,094 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,816 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
6,944 KB
testcase_07 WA -
testcase_08 AC 2 ms
6,940 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
6,940 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:22:23: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Data.List, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
   |
22 | elemO v xs = (v ==) $ head $ dropWhile (v <) xs
   |                       ^^^^
[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 && elemO (div total 2) (make ws1) where
  total = sum ws
  ws1 = sort ws

make [] = [0]
make (x:xs) = merge ws $ map (x+) ws where ws = make xs

merge xxs@(x:xs) yys@(y:ys)
 | x < y = x : merge xs yys
 | x > y = y : merge xxs ys
 | True  = x : merge xs ys

elemO v xs = (v ==) $ head $ dropWhile (v <) xs
0