結果

問題 No.4 おもりと天秤
ユーザー LeonardoneLeonardone
提出日時 2015-10-30 01:10:16
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 534 bytes
コンパイル時間 2,022 ms
コンパイル使用メモリ 164,128 KB
実行使用メモリ 7,680 KB
最終ジャッジ日時 2023-10-11 05:26:17
合計ジャッジ時間 2,291 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 2 ms
6,860 KB
testcase_02 AC 7 ms
7,008 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 RE -
testcase_06 AC 2 ms
6,984 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 2 ms
7,024 KB
testcase_12 AC 3 ms
7,088 KB
testcase_13 AC 2 ms
6,948 KB
testcase_14 AC 3 ms
7,084 KB
testcase_15 AC 3 ms
7,008 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #

-- yukicoder My Practice
-- author: Leonardone @ NEETSDKASU
-- http://yukicoder.me/problems/19

import Data.Bits

main = do
    n <- readLn
    w <- getLine
    putStrLn $ main' n w

main' n ws =
    let
        w = map read $ words ws
        s = foldl1 (+) w `div` 2
        a = zip [1..n] w
        x = shiftL (1::Int) n
    in
        solve s (x - 1) a

solve _ 0 _ = "impossible"
solve n x a =
    if n == foldl calc x a
        then "possible"
        else solve n (x - 1) a
        
calc x (i,e) = if testBit i x then e else 0
0