結果
| 問題 | No.4 おもりと天秤 |
| コンテスト | |
| ユーザー |
pocarist
|
| 提出日時 | 2015-09-01 18:57:57 |
| 言語 | F# (F# 10.0) |
| 結果 |
AC
|
| 実行時間 | 49 ms / 5,000 ms |
| コード長 | 681 bytes |
| 記録 | |
| コンパイル時間 | 11,498 ms |
| コンパイル使用メモリ | 212,376 KB |
| 実行使用メモリ | 34,696 KB |
| 最終ジャッジ日時 | 2026-03-13 01:40:34 |
| 合計ジャッジ時間 | 13,445 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (195 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.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
pocarist