結果
| 問題 |
No.617 Nafmo、買い出しに行く
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-23 04:20:09 |
| 言語 | F# (F# 4.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,059 bytes |
| コンパイル時間 | 14,723 ms |
| コンパイル使用メモリ | 195,012 KB |
| 実行使用メモリ | 58,448 KB |
| 最終ジャッジ日時 | 2024-07-20 05:39:04 |
| 合計ジャッジ時間 | 21,313 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 WA * 5 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (388 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/
ソースコード
let combination f lst =
let rec combination' restLst curLst =
match restLst with
| [] -> ()
| e :: rest ->
let curLst' = e :: curLst
if f curLst' then
combination' rest curLst'
combination' rest curLst
combination' lst []
exception RecursiveFinish
let solve aLst k =
let mutable result = 0
try
combination
(fun lst ->
let sum = List.sum lst
if sum = k then
result <- k
raise RecursiveFinish
else
if result < sum && sum < k then
result <- sum
sum < k)
aLst
with
| RecursiveFinish -> ()
printfn "%d" result
let () =
let n, k =
stdin.ReadLine()
|> fun s -> s.Split()
|> fun arr -> (int arr.[0], int arr.[1])
let aLst =
seq {
for _ in 1..n -> stdin.ReadLine() |> int
}
|> Seq.toList
solve aLst k