結果
問題 | No.4 おもりと天秤 |
ユーザー | e7a894 |
提出日時 | 2018-05-18 19:16:29 |
言語 | Haskell (9.6.2) |
結果 |
MLE
|
実行時間 | - |
コード長 | 464 bytes |
コンパイル時間 | 9,649 ms |
コンパイル使用メモリ | 158,096 KB |
実行使用メモリ | 807,468 KB |
最終ジャッジ日時 | 2023-09-10 22:54:47 |
合計ジャッジ時間 | 13,615 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
7,028 KB |
testcase_01 | AC | 3 ms
6,996 KB |
testcase_02 | AC | 12 ms
12,044 KB |
testcase_03 | AC | 3 ms
7,244 KB |
testcase_04 | AC | 4 ms
8,516 KB |
testcase_05 | MLE | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
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
ソースコード
import Data.List main = do n <- readLn :: IO Int ws <- (map read . words) <$> getLine putStrLn $ if odd (sum ws) then "impossible" else resolve ws resolve ws = resolve' (powerset (reverse (takeWhile (< wt) $ sort ws))) wt where wt = (sum ws) `div` 2 resolve' [] _ = "impossible" resolve' (x:xs) a | sum x == a = "possible" | otherwise = resolve' xs a powerset [] = [[]] powerset (x:xs) = [x:ps | ps <- powerset xs] ++ powerset xs