結果

問題 No.5 数字のブロック
ユーザー OldBrid21501053OldBrid21501053
提出日時 2019-09-30 23:44:14
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 467 bytes
コンパイル時間 9,125 ms
コンパイル使用メモリ 195,140 KB
実行使用メモリ 37,660 KB
最終ジャッジ日時 2024-04-14 08:23:28
合計ジャッジ時間 19,836 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 331 ms
34,608 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 337 ms
34,636 KB
testcase_21 AC 337 ms
35,020 KB
testcase_22 AC 335 ms
34,624 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 337 ms
34,632 KB
testcase_27 AC 338 ms
34,996 KB
testcase_28 AC 334 ms
34,496 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 331 ms
34,204 KB
testcase_32 AC 333 ms
34,488 KB
testcase_33 AC 338 ms
34,600 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (238 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/

ソースコード

diff #

open System

let rec solve (i : int) (sum : int) (l : int) (n : int) (ws : int array) =
    if i = n then n
    else 
        let s = sum + ws.[i]
        if s > l then l
        else solve (i + 1) (sum + ws.[i]) l n ws

[<EntryPoint>]
let main _ =
    let l  = stdin.ReadLine() |> int
    let n  = stdin.ReadLine() |> int
    let ws = stdin.ReadLine().Split(' ') |> Array.map int |> Array.sort
    printfn "%d" (solve 0 0 l n ws)
    0 // return an integer exit code
0