結果

問題 No.4 おもりと天秤
ユーザー regeregeregerege
提出日時 2015-10-18 12:56:32
言語 F#
(F# 4.0)
結果
AC  
実行時間 190 ms / 5,000 ms
コード長 582 bytes
コンパイル時間 3,292 ms
コンパイル使用メモリ 160,864 KB
実行使用メモリ 31,080 KB
最終ジャッジ日時 2023-09-08 16:26:31
合計ジャッジ時間 6,818 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
24,984 KB
testcase_01 AC 82 ms
22,868 KB
testcase_02 AC 85 ms
22,844 KB
testcase_03 AC 83 ms
22,820 KB
testcase_04 AC 84 ms
22,820 KB
testcase_05 AC 143 ms
29,128 KB
testcase_06 AC 85 ms
24,972 KB
testcase_07 AC 144 ms
29,176 KB
testcase_08 AC 82 ms
22,892 KB
testcase_09 AC 190 ms
27,456 KB
testcase_10 AC 149 ms
27,156 KB
testcase_11 AC 85 ms
22,916 KB
testcase_12 AC 84 ms
23,020 KB
testcase_13 AC 84 ms
22,792 KB
testcase_14 AC 85 ms
22,872 KB
testcase_15 AC 85 ms
22,928 KB
testcase_16 AC 84 ms
22,916 KB
testcase_17 AC 84 ms
22,956 KB
testcase_18 AC 139 ms
31,080 KB
testcase_19 AC 135 ms
29,040 KB
testcase_20 AC 136 ms
27,096 KB
testcase_21 AC 133 ms
27,156 KB
testcase_22 AC 135 ms
29,116 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

let ``No.4 おもりと天秤`` () =
    let c = int(stdin.ReadLine()) - 1
    let l =
        stdin.ReadLine().Split(' ')
        |> Seq.map int
        |> Seq.toList
    let m = List.sum l
    let p =
        if m &&& 1 = 1 then 0
        else
            let m2 = m/2
            let dp = Array.init 10000 (fun _ -> 0)
            dp.[0] <- 1
            for i in 0..c do
                for j in (seq[m2..(-1)..(l.[i])]) do
                    dp.[j] <- (dp.[j] ||| dp.[j-l.[i]])
            dp.[m2]
    printfn "%s" ["impossible";"possible";].[p]
``No.4 おもりと天秤`` ()
0