import math

import itertools

import sys

input = sys.stdin.readline



def main():

    D, G = list(map(int, input().split()))

    spc_list = [[(i+1) * 100] + [int(v) for v in input().split()] for i in range(D)]

    max_scores = [spc[0] * spc[1] + spc[2] for spc in spc_list]

    min_q = float("inf")

    for q_list in itertools.permutations(list(range(D))):

        score = 0

        q_num = 0

        for q_idx in q_list:

            if score + max_scores[q_idx] < G:

                score += max_scores[q_idx]

                q_num += spc_list[q_idx][1]

            else:

                q_num += min(math.ceil((G-score) / spc_list[q_idx][0]), spc_list[q_idx][1])

                score = G

                """

                for _ in range(spc_list[q_idx][1]):

                    score += spc_list[q_idx][0]

                    q_num += 1

                    if score >= G:

                        break

                score += spc_list[q_idx][2]

"""

            if score >= G:

                break

        if q_num < min_q:

            min_q = q_num

    print(min_q)





if __name__ == '__main__':

    main()

import math



def dfs(i, sum, count, remain, d, g, pc):

    global ans

    if i == d:

        if sum < g:

            q = max(remain)

            n = min(pc[q][0] - 1, math.ceil((g - sum) / (100 * (q + 1))))

            #n = min(pc[q][0], -(-(g - sum) // ((q + 1) * 100)))

            count += n

            sum += 100 * (q + 1) * n

        if sum >= g:

            ans = min(ans, count)

    else:

        dfs(i + 1, sum, count, remain, d, g, pc)

        dfs(i + 1, sum + (i + 1) * 100 * pc[i][0] + pc[i][1], count + pc[i][0], remain - {i}, d, g, pc)



def main2():

    global ans

    ans = float("inf")

    d, g = list(map(int, input().split()))

    pc = [list(map(int, input().split())) for _ in range(d)]

    dfs(0, 0, 0, set(range(d)), d, g, pc)

    print(ans)



if __name__ == '__main__':

    main2()
import math
import itertools
import sys

input = sys.stdin.readline


def main():
    D, G = list(map(int, input().split()))
    spc_list = [[(i + 1) * 100] + [int(v) for v in input().split()] for i in range(D)]
    max_scores = [spc[0] * spc[1] + spc[2] for spc in spc_list]
    min_q = float("inf")
    for q_list in itertools.permutations(list(range(D))):
        score = 0
        q_num = 0
        for q_idx in q_list:
            if score + max_scores[q_idx] < G:
                score += max_scores[q_idx]
                q_num += spc_list[q_idx][1]
            else:
                q_num += min(
                    math.ceil((G - score) / spc_list[q_idx][0]), spc_list[q_idx][1]
                )
                score = G
                """
                for _ in range(spc_list[q_idx][1]):
                    score += spc_list[q_idx][0]
                    q_num += 1
                    if score >= G:
                        break
                score += spc_list[q_idx][2]
"""
            if score >= G:
                break
        if q_num < min_q:
            min_q = q_num
    print(min_q)


if __name__ == "__main__":
    main()

import math


def dfs(i, sum, count, remain, d, g, pc):
    global ans
    if i == d:
        if sum < g:
            q = max(remain)
            n = min(pc[q][0] - 1, math.ceil((g - sum) / (100 * (q + 1))))
            # n = min(pc[q][0], -(-(g - sum) // ((q + 1) * 100)))
            count += n
            sum += 100 * (q + 1) * n
        if sum >= g:
            ans = min(ans, count)
    else:
        dfs(i + 1, sum, count, remain, d, g, pc)
        dfs(
            i + 1,
            sum + (i + 1) * 100 * pc[i][0] + pc[i][1],
            count + pc[i][0],
            remain - {i},
            d,
            g,
            pc,
        )


def main2():
    global ans
    ans = float("inf")
    d, g = list(map(int, input().split()))
    pc = [list(map(int, input().split())) for _ in range(d)]
    dfs(0, 0, 0, set(range(d)), d, g, pc)
    print(ans)


if __name__ == "__main__":
    main2()

-import itertools -import sys - -input = sys.stdin.readline -def main(): -    D, G = list(map(int, input().split())) -    spc_list = [[(i + 1) * 100] + [int(v) for v in input().split()] for i in range(D)] -    max_scores = [spc[0] * spc[1] + spc[2] for spc in spc_list] -    min_q = float("inf") -    for q_list in itertools.permutations(list(range(D))): -        score = 0 -        q_num = 0 -        for q_idx in q_list: -            if score + max_scores[q_idx] < G: -                score += max_scores[q_idx] -                q_num += spc_list[q_idx][1] -            else: -                q_num += min( -                    math.ceil((G - score) / spc_list[q_idx][0]), spc_list[q_idx][1] -                ) -                score = G -                """ -                for _ in range(spc_list[q_idx][1]): -                    score += spc_list[q_idx][0] -                    q_num += 1 -                    if score >= G: -                        break -                score += spc_list[q_idx][2] -""" -            if score >= G: -                break -        if q_num < min_q: -            min_q = q_num -    print(min_q) +def dfs(i, sum, count, remain, d, g, pc): +    global ans +    if i == d: +        if sum < g: +            q = max(remain) +            n = min(pc[q][0] - 1, math.ceil((g - sum) / (100 * (q + 1)))) +            # n = min(pc[q][0], -(-(g - sum) // ((q + 1) * 100))) +            count += n +            sum += 100 * (q + 1) * n +        if sum >= g: +            ans = min(ans, count) +    else: +        dfs(i + 1, sum, count, remain, d, g, pc) +        dfs( +            i + 1, +            sum + (i + 1) * 100 * pc[i][0] + pc[i][1], +            count + pc[i][0], +            remain - {i}, +            d, +            g, +            pc, +        ) + + +def main2(): +    global ans +    ans = float("inf") +    d, g = list(map(int, input().split())) +    pc = [list(map(int, input().split())) for _ in range(d)] +    dfs(0, 0, 0, set(range(d)), d, g, pc) +    print(ans) -    main() +    main2()