Language Test

Submission #1290310

Source codeソースコード

open Num
open Scanf
open Printf
       
type info = {v : int ; w : int}

let () = 
  let n, w = scanf "%d %d\n" (fun x y -> (x, y)) in
  let tbl = Hashtbl.create n in
  let info = Array.init n (fun _ -> scanf "%d %d\n" (fun x y -> {v = x; w = y})) in
  let rec max_value i j =
    if i = 0 then
      if info.(i).w > j then num_of_int 0 else num_of_int info.(i).v
    else
      try
        Hashtbl.find tbl (i, j)
      with
        Not_found -> if info.(i).w > j then max_value (i - 1) j
                     else
                       let tv = max_num (num_of_int info.(i).v +/ (max_value (i - 1) (j - info.(i).w))) (max_value (i - 1) j) in
                       Hashtbl.add tbl (i, j) tv; tv
  in
  max_value (n-1) w |> string_of_num |> printf "%s\n"

Submission

Task問題 I - ナップサック問題
User nameユーザ名 ducktail
Created time投稿日時
Language言語 OCaml (4.02.3)
Status状態 TLE
Score得点 34
Source lengthソースコード長 780 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - subtask00_sample_1.txt,subtask00_sample_2.txt,subtask00_sample_3.txt,subtask00_sample_4.txt
Subtask1 34 / 34 subtask01_0.txt,subtask01_1.txt,subtask01_10.txt,subtask01_11.txt,subtask01_12.txt,subtask01_13.txt,subtask01_14.txt,subtask01_2.txt,subtask01_3.txt,subtask01_4.txt,subtask01_5.txt,subtask01_6.txt,subtask01_7.txt,subtask01_8.txt,subtask01_9.txt,subtask00_sample_1.txt,subtask00_sample_2.txt,subtask00_sample_3.txt,subtask00_sample_4.txt
Subtask2 0 / 33 subtask02_0.txt,subtask02_1.txt,subtask02_10.txt,subtask02_11.txt,subtask02_12.txt,subtask02_13.txt,subtask02_14.txt,subtask02_2.txt,subtask02_3.txt,subtask02_4.txt,subtask02_5.txt,subtask02_6.txt,subtask02_7.txt,subtask02_8.txt,subtask02_9.txt,subtask00_sample_1.txt,subtask00_sample_3.txt
Subtask3 0 / 33 subtask03_0.txt,subtask03_1.txt,subtask03_10.txt,subtask03_11.txt,subtask03_2.txt,subtask03_3.txt,subtask03_4.txt,subtask03_5.txt,subtask03_6.txt,subtask03_7.txt,subtask03_8.txt,subtask03_9.txt,subtask00_sample_1.txt,subtask00_sample_4.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask00_sample_1.txt AC 1 ms 384 KB
subtask00_sample_2.txt AC 2 ms 896 KB
subtask00_sample_3.txt AC 1 ms 512 KB
subtask00_sample_4.txt AC 1 ms 384 KB
subtask01_0.txt AC 2 ms 896 KB
subtask01_1.txt AC 2 ms 640 KB
subtask01_10.txt AC 1 ms 512 KB
subtask01_11.txt AC 1 ms 512 KB
subtask01_12.txt AC 2 ms 896 KB
subtask01_13.txt AC 1 ms 384 KB
subtask01_14.txt AC 1 ms 640 KB
subtask01_2.txt AC 1 ms 384 KB
subtask01_3.txt AC 1 ms 512 KB
subtask01_4.txt AC 1 ms 2432 KB
subtask01_5.txt AC 1 ms 512 KB
subtask01_6.txt AC 1 ms 384 KB
subtask01_7.txt AC 1 ms 384 KB
subtask01_8.txt AC 6 ms 2432 KB
subtask01_9.txt AC 1 ms 384 KB
subtask02_0.txt TLE
subtask02_1.txt TLE
subtask02_10.txt TLE
subtask02_11.txt TLE
subtask02_12.txt TLE
subtask02_13.txt AC 11 ms 5504 KB
subtask02_14.txt AC 1600 ms 121464 KB
subtask02_2.txt TLE
subtask02_3.txt TLE
subtask02_4.txt TLE
subtask02_5.txt AC 1043 ms 82172 KB
subtask02_6.txt TLE
subtask02_7.txt TLE
subtask02_8.txt TLE
subtask02_9.txt TLE
subtask03_0.txt AC 76 ms 6144 KB
subtask03_1.txt TLE
subtask03_10.txt AC 14 ms 2816 KB
subtask03_11.txt AC 2 ms 1024 KB
subtask03_2.txt TLE
subtask03_3.txt TLE
subtask03_4.txt TLE
subtask03_5.txt TLE
subtask03_6.txt AC 36 ms 5760 KB
subtask03_7.txt TLE
subtask03_8.txt TLE
subtask03_9.txt TLE