結果
問題 | No.4 おもりと天秤 |
ユーザー |
![]() |
提出日時 | 2015-09-01 18:57:57 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 81 ms / 5,000 ms |
コード長 | 681 bytes |
コンパイル時間 | 14,917 ms |
コンパイル使用メモリ | 193,044 KB |
実行使用メモリ | 32,640 KB |
最終ジャッジ日時 | 2024-06-26 09:18:01 |
合計ジャッジ時間 | 17,784 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (384 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
(* http://yukicoder.me/problems/19 *) open System [<EntryPoint>] let main argv = let N = Console.ReadLine() |> int let W = Console.ReadLine().Split([|' '|]) |> Array.map int let total = Array.sum W let U = total / 2 let solve () = if U * 2 <> total then false else let dp = Array2D.zeroCreate<int> (N+1) (U+1) for i = N-1 downto 0 do for u = 0 to U do if u < W.[i] then dp.[i,u] <- dp.[i+1,u] else dp.[i,u] <- max dp.[i+1,u] (dp.[i+1,u-W.[i]] + W.[i]) dp.[0, U] = U if solve () then "possible" else "impossible" |> printfn "%s" 0