結果

問題 No.617 Nafmo、買い出しに行く
ユーザー taktak
提出日時 2019-02-21 12:13:45
言語 F#
(F# 4.0)
結果
AC  
実行時間 512 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 3,932 ms
コンパイル使用メモリ 169,560 KB
実行使用メモリ 24,404 KB
最終ジャッジ日時 2023-08-11 00:02:19
合計ジャッジ時間 11,005 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
24,404 KB
testcase_01 AC 60 ms
24,388 KB
testcase_02 AC 59 ms
20,428 KB
testcase_03 AC 79 ms
24,404 KB
testcase_04 AC 58 ms
22,328 KB
testcase_05 AC 101 ms
20,316 KB
testcase_06 AC 507 ms
20,316 KB
testcase_07 AC 498 ms
24,396 KB
testcase_08 AC 59 ms
22,360 KB
testcase_09 AC 58 ms
20,484 KB
testcase_10 AC 495 ms
22,340 KB
testcase_11 AC 505 ms
22,352 KB
testcase_12 AC 499 ms
22,324 KB
testcase_13 AC 504 ms
22,488 KB
testcase_14 AC 512 ms
22,556 KB
testcase_15 AC 501 ms
22,280 KB
testcase_16 AC 504 ms
22,344 KB
testcase_17 AC 500 ms
22,412 KB
testcase_18 AC 60 ms
24,388 KB
testcase_19 AC 61 ms
22,420 KB
testcase_20 AC 61 ms
22,356 KB
testcase_21 AC 60 ms
22,476 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

open System

type [<Measure>] kg

let bitDP (xs: int64<kg> list) n k =
  let mutable ans = 0L<kg>
  for i in 0 .. (1 <<< n) do
    let mutable sum = 0L<kg>
    for j in 0 .. (n-1) do
      if ((i >>> j) &&& 1) = 1 then sum <- sum + xs.[j]
    if sum <= k then ans <- max ans sum 
  ans
  
let N, K =
  let t = Console.ReadLine().Split()
  (t.[0] |> int), (t.[1] |> int64 |> (*) 1L<kg>)
  
let A = List.init N (fun _ ->
  Console.ReadLine() |> int64 |> (*)1L<kg>)

bitDP A N K
|> Console.WriteLine
0