結果

問題 No.4 おもりと天秤
ユーザー taktak
提出日時 2018-04-12 19:46:57
言語 F#
(F# 4.0)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 488 bytes
コンパイル時間 3,154 ms
コンパイル使用メモリ 156,440 KB
実行使用メモリ 24,688 KB
最終ジャッジ日時 2023-09-09 04:25:48
合計ジャッジ時間 6,038 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
22,716 KB
testcase_01 AC 81 ms
22,652 KB
testcase_02 AC 81 ms
22,684 KB
testcase_03 AC 80 ms
22,676 KB
testcase_04 AC 81 ms
22,640 KB
testcase_05 AC 83 ms
22,660 KB
testcase_06 AC 81 ms
22,648 KB
testcase_07 AC 84 ms
24,668 KB
testcase_08 AC 80 ms
22,696 KB
testcase_09 AC 83 ms
22,760 KB
testcase_10 AC 83 ms
22,720 KB
testcase_11 AC 81 ms
22,812 KB
testcase_12 AC 80 ms
22,664 KB
testcase_13 AC 80 ms
22,672 KB
testcase_14 AC 80 ms
24,688 KB
testcase_15 AC 81 ms
22,680 KB
testcase_16 AC 80 ms
22,680 KB
testcase_17 AC 80 ms
22,668 KB
testcase_18 AC 83 ms
22,628 KB
testcase_19 AC 83 ms
20,624 KB
testcase_20 AC 84 ms
22,684 KB
testcase_21 AC 83 ms
22,692 KB
testcase_22 AC 84 ms
22,672 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

let size = 100*100+5
let N    = stdin.ReadLine() |> int
let W    = stdin.ReadLine().Split() |> Array.map(int)
let sum  = W |> Array.sum
if sum%2 = 0 then 
    let dp = Array.zeroCreate size
    dp.[0] <- true    
    W
    |> Array.iter (fun x ->
        for i in size-1 .. (-1) .. 0 do
            if dp.[i] then
                dp.[i+x] <- true)                            
    if dp.[sum/2] then "possible"
    else               "impossible"
else 
    "impossible"
|> printfn "%s"    
0