Scanf.scanf "%d %d" (fun d g ->
    let pc = Array.init d (fun _ -> Scanf.scanf " %d %d" (fun p c -> p, c)) in

    let rec loop bits mi =
        let rec loop2 j bits score count =
            if bits = 0 then score, count else
                let p,c = pc.(j) in
                if bits land 1 = 1 then loop2 (j + 1) (bits lsr 1) (score + 100 * (j + 1) * p + c) (count + p)
                                   else loop2 (j + 1) (bits lsr 1) score count
        in
        let rec find_bits i =
            if i < 0 then i else
                if (1 lsl i) land bits = 0 then i else find_bits (i - 1)
        in
        if bits < 0 then mi else
            let score, count = loop2 0 bits 0 0 in
            let mi = if score >= g then min mi count else
                let k = find_bits (d - 1) in
                if k < 0 then mi else
                    let p, _ = pc.(k) in
                    let kk = (k + 1) * 100 in
                    let q = (g - score + kk - 1) / kk in
                    if q < p then min mi (count + q) else mi
            in
            loop (bits - 1) mi
    in
    loop ((1 lsl d) - 1) max_int |> Printf.printf "%d\n"
)