Problem:
 Score : 300 points    Problem Statement A programming competition site AtCode provides algorithmic problems.
Each problem is allocated a score based on its difficulty.
Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.
These p_1 + … + p_D problems are all of the problems available on AtCode.  A user of AtCode has a value called total score .
The total score of a user is the sum of the following two elements:   Base score: the sum of the scores of all problems solved by the user.  Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D) .   Takahashi, who is the new user of AtCode, has not solved any problem.
His objective is to have a total score of G or more points.
At least how many problems does he need to solve for this objective?      Constraints  1 ≤ D ≤ 10  1 ≤ p_i ≤ 100  100 ≤ c_i ≤ 10^6  100 ≤ G  All values in input are integers.  c_i and G are all multiples of 100 .  It is possible to have a total score of G or more points.         Input Input is given from Standard Input in the following format:  D  G  p_1  c_1  :  p_D  c_D       Output Print the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).        Sample Input 1 2 700
3 500
5 800      Sample Output 1 3  In this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100 -point problems is 500 points, and the perfect bonus for solving all the 200 -point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.  One way to achieve this objective is to solve four 200 -point problems and earn a base score of 800 points. However, if we solve three 100 -point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.       Sample Input 2 2 2000
3 500
5 800      Sample Output 2 7  This case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200 -point problems, and by solving two 100 -point problems additionally we have the total score of 2000 points.       Sample Input 3 2 400
3 500
5 800      Sample Output 3 2  This case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200 -point problems to achieve the objective.       Sample Input 4 5 25000
20 1000
40 1000
50 1000
30 1000
1 1000      Sample Output 4 66  There is only one 500 -point problem, but the perfect bonus can be earned even in such a case.

Solution (Python):
I=lambda:map(int,input().split())
divup=lambda x,y:(x+y-1)//y
D,G=I()
P={};C={};Score={}
for i in range(D):P[i],C[i]=I();Score[i]=-~i*100*P[i]+C[i]
r=1e9+7
for k in range(1<<D):
    str_branch=str(bin(k))[2:].rjust(D,'0')
    probs=0;score=0
    for i,b in enumerate(str_branch):
        if b=='1':probs+=P[i];score+=Score[i]
    if score>=G:r=min(r,probs);continue
    for i in range(D)[::-1]:
        pi=-~i*100
        if str_branch[i]=='0' and G-score<pi*P[i]:
            r=min(r,probs+divup(G-score,pi));break
print(r)

Solution (Python):
D, G = map(int,input().split())
L = []
ans = []
def ceil(i):
    if int(i) == i:
        return int(i)
    else:
        return int(i)+1


for _ in range(D):
    l = list(map(int,input().split())) +[0]
    L.append(l)
for k in range(2**D):
    value = 0
    b = format(k,'b').zfill(D)
    l = list(map(int,list(b)))
    cnt = 0
    for i in range(D):
        if l[i]:
            L[i][2] = 1
            value += L[i][1]
            value += L[i][0]*((i+1)*100)
            cnt += L[i][0]
        else:
            L[i][2] = 0
    remain = list(filter(lambda x:x[2]==0,L))[::-1]
    j = len(remain)

    if G - value > 0:
        while True:
            if remain==[]:
                cnt = 10**100
                break
            tmp = remain.pop(0)
            if G - value <= (j*100)*(tmp[0] - 1):
 
                cnt += ceil((G-value)/(j*100))
                break
            else:
                cnt += tmp[0]-1
                value += (j*100)*(tmp[0]-1)
                j -= 1
    ans.append(cnt)

print(min(ans))

Solution (Python):
D,G = map(int,input().split())
pc = [list(map(int,input().split())) for _ in range(D)]
ans = float('inf')
for i in range(1<<D):
    score = 0
    cnt = 0
    for j in range(D):
        if i&(1<<j):
            score += pc[j][0]*(j+1)*100+pc[j][1]
            cnt += pc[j][0]
    if score>=G:
        ans = min(ans,cnt)
    else:
        for j in range(D)[::-1]:
            if i&(1<<j):
                continue
            for k in range(pc[j][0]):
                score += 100*(j+1)
                cnt += 1
                if score>=G:
                    break
            if score>=G:
                break
        ans = min(ans,cnt)
print(ans)

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

L=[0]+[list(map(int, input().split())) for i in range(D)]
 

def f(G, i):
    if i==0:
	    return 10000
    
    n=min(G//(i*100), L[i][0])
    
    s=n*i*100
    
    if n==L[i][0]:
        s+=L[i][1]
	
    if s<G:
        n+=f(G-s, i-1)
    
    return min(n, f(G,i-1))
print(f(G, D))

Solution (Python):
D, G = map(int,input().split())
pc = [list(map(int,input().split())) for _ in range(D)]

ans = 10**9+7

for i in range(1 << D):
  point = 0
  count = 0
  tmp = []
  
    
    
  for j in range(D):
    if(((i >> j) & 1) == 1):
      point += pc[j][0] * 100 * (j + 1) + pc[j][1]
      count += pc[j][0]
    else:
      tmp.append(j)
  if(point < G):
    R = G - point
    k = tmp[-1]
    if((pc[k][0] - 1) * (k + 1) * 100 < R):
      continue
    count += -(-R // (100 * (k + 1)))
  ans = min(ans, count)
print(ans)

Solution (Python):
d,g=map(int,input().split())
data=[]
for i in range(d):
    p,c=map(int,input().split())
    data.append((p,c))
n=0
mn=99999999
while n<2**d:
    point=0
    count=0
    for i in range(d):
        if n&(1<<i):
            point+=data[i][0]*100*(i+1)+data[i][1]
            count+=data[i][0]
    if point<g:
        for i in range(d):
            i=d-1-i
            if not n&(1<<i):
                for j in range(data[i][0]-1):
                    point+=(i+1)*100
                    count+=1
                    if point>=g:
                        mn=min(mn,count)
                        break
                else:
                    break
                break
    else:
        mn=min(mn,count)
    n+=1
print(mn)

Solution (Python):
D, G=list(map(int, input().split()))
PC=[0]+[list(map(int, input().split())) for _ in range(D)]

def function(G, i):
    
    if i==0:
	    return 1001
    n=min(G//(i*100), PC[i][0])
    
    s=n*i*100
    
    if n==PC[i][0]:
        s+=PC[i][1]
        
    if s<G:
        n+=function(G-s, i-1)
        
    return min(n, function(G,i-1))
print(function(G, D))

Solution (Python):
d, g = map(int, input().split())
PC = [0] + [[i for i in map(int, input().split())] for i in range(d)]

def dfs(g, i):
    if i == 0:
        return 10 ** 12
    
    cnt = min(g // (100 * i), PC[i][0])
    score = cnt * 100 * i
    
    if cnt == PC[i][0]:
        score += PC[i][1]
        
    if g > score:
        cnt += dfs(g - score, i - 1)
    
    return min(cnt, dfs(g, i - 1))

print(dfs(g, d))

Solution (Python):
d, g = map(int, input().split())
PC = [0] + [[int(i) for i in input().split()] for i in range(d)]

def dfs(g, i):
    if i == 0:
        return 10 ** 12
    
    n = min(g // (100 * i), PC[i][0])
    score = n * 100 * i
    
    if n == PC[i][0]:
        score += PC[i][1]
        
    if g > score:
        n += dfs(g - score, i - 1)
        
    return min(n, dfs(g, i - 1))

print(dfs(g, d))

Solution (Python):

D,G = map(int, input().split())
points = [ [int(j) for j in input().split()] for _ in range(D)]
points = [ [x[0], x[1], 100*e*x[0]] for e,x in enumerate(points, 1)]

ans = float("inf")
for i in range(1<<D): 
    lg = G
    cnt = 0
    for d in range(D):
        if i & (1<<d) != 0:
            lg -= points[d][1] 
            
            lg -= points[d][2] 
            cnt += points[d][0]
            if lg <= 0:
                break
    if lg <= 0:
        ans = min(ans, cnt)
        continue
    
    
    for d in range(D-1, -1, -1):
        if i & (1<<d) != 0: continue

        if lg <= points[d][2]:
            quot = (lg+(100*(d+1)-1)) // (100*(d+1)) 
            lg -= 100*(d+1)*quot
            cnt += quot;  break
        else:
            cnt += points[d][0]
            lg -= points[d][2]
    if lg <= 0:
        ans = min(ans, cnt)
        continue
print(ans)

Solution (Python):

D,G = map(int, input().split())
points = [ [int(j) for j in input().split()] for _ in range(D)]
points = [ [x[0], x[1], 100*e*x[0]] for e,x in enumerate(points, 1)]


ans = float("inf")
for i in range(1<<D): 
    lg = G
    cnt = 0
    for d in range(D):
        if i & (1<<d) != 0:
            lg -= points[d][1] 
            lg -= (100*(d+1))*points[d][0] 
            cnt += points[d][0]
            if lg <= 0:
                break
    if lg <= 0:
        ans = min(ans, cnt)
        continue
    
    
    for d in range(D-1, -1, -1):
        if i & (1<<d) != 0: continue

        if lg <= points[d][2]:
            quot = (lg+(100*(d+1)-1)) // (100*(d+1))
            lg -= 100*(d+1)*quot
            cnt += quot;  break
        else:
            cnt += points[d][0]
            lg -= 100*(d+1)*points[d][0]
            cnt += points[d][0]
    if lg <= 0:
        ans = min(ans, cnt)
        continue
print(ans)

Solution (Python):
def solve(D, G, PCs):
    
    ans = 10000
    for d in range(0, 2 ** D):
        b = "{:011b}".format(d)[::-1][:D]
        k = 0
        point = 0
        for i, c in enumerate(b):
            if c == "1":
                k += PCs[i][0]
                point += PCs[i][1] + ((i + 1) * 100 * PCs[i][0])
        if point >= G:
            ans = min(ans, k)
            continue

        for i, (p, c) in enumerate(PCs[::-1]):
            if b[D - (i + 1)] == "1":
                continue
            for _ in range(p):
                point += (D - i) * 100
                k += 1
                if point >= G:
                    break
            if point >= G:
                break
        ans = min(ans, k)
    return ans

if __name__ == "__main__":
    D, G = tuple(map(int, input().split(" ")))
    PCs = [tuple(map(int, input().split(" "))) for _ in range(D)]
    print(solve(D, G, PCs))

Solution (Python):
import itertools, math
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]
ans = float('inf')
comb = list(itertools.product([0, 1], repeat=d))
for i in range(len(comb)):
    s = 0
    c = 0
    for j in range(d):
        if comb[i][j] == 1:
            s += pc[j][0] * (j + 1) * 100 + pc[j][1]
            c += pc[j][0]
    div = g - s
    if div <= 0:
        ans = min(ans, c)
        continue
    for j in range(d):
        tmpdiv = div
        tmpc = c
        if comb[i][j] == 0:
            cut = min(tmpdiv // math.ceil((j + 1) * 100), pc[j][0] - 1)
            tmpc += cut
            tmpdiv -= cut * (j + 1) * 100
            if tmpdiv <= 0:
                ans = min(ans, tmpc)
print(ans)

Solution (Python):

d,g = map(int,input().split())
q={}
comp={}
p={}
minsolve=0
for i in range(d):
    a,b=map(int,input().split())
    q[i]=a
    p[i]=100*(i+1)
    comp[i]=100*(i+1)*a+b
    minsolve+=a
    
solve=[0 for _ in range(d)]
def roop(s,check,point,solved,minsolve):
    solve=s.copy()
    solve2=s.copy()
    if check==d:
        if 0 in solve:
            solverev=solve.copy()
            solverev.reverse()
            idx=d-solverev.index(0)-1
            shold=max(0,1+(g-point-1)//p[idx])
            if q[idx]>shold and shold>=0:
                solved+=shold
                minsolve=min(minsolve,solved)
        return minsolve

    minsolve=roop(solve,check+1,point,solved,minsolve)
    solve2[check]+=1
    minsolve=roop(solve2,check+1,point+comp[check],solved+q[check],minsolve)
    return minsolve

print(roop(solve,0,0,0,minsolve))

Solution (Python):
d,g = map(int,input().split())
q={}
comp={}
p={}
minsolve=0
for i in range(d):
    a,b=map(int,input().split())
    q[i]=a
    p[i]=100*(i+1)
    comp[i]=100*(i+1)*a+b
    minsolve+=a
    
solve=[0 for _ in range(d)]
def roop(s,check,point,solved,minsolve):
    solve=s.copy()
    solve2=s.copy()
    if check==d:
        if point>g:
            minsolve=min(minsolve,solved)
            return minsolve
        if 0 in solve:
            solverev=solve.copy()
            solverev.reverse()
            idx=d-solverev.index(0)-1
            shold=1+(g-point-1)//p[idx]
            if q[idx]>shold and shold>=0:
                solved+=shold
                minsolve=min(minsolve,solved)
        return minsolve

    minsolve=roop(solve,check+1,point,solved,minsolve)
    solve2[check]+=1
    minsolve=roop(solve2,check+1,point+comp[check],solved+q[check],minsolve)
    return minsolve

print(roop(solve,0,0,0,minsolve))

Solution (Python):
import numpy as np
d, g = map(int ,input().split())
points = [list(map(int,input().split())) for _ in range(d)]

def min_q(comp_flg, target_score): 
    score = 0
    q_num = 0
    for i in range(d-1,-1,-1):
        if comp_flg[i]:
            continue
        if target_score>score+points[i][0]*(i+1)*100:
            score += points[i][0]*(i+1)*100
            q_num += points[i][0] 
        else:
            q_num += np.ceil((target_score-score)/(100*(i+1)))
            break
    return q_num


mn = float('inf')
for i in range(1<<d):
    complete_flg = [False]*d
    tmp_q_num = 0
    tmp_point = 0
    for j in range(d):
        if i&(2**j) != 0:
            tmp_point += points[j][0] * 100*(j+1) + points[j][1]
            complete_flg[j] = True
            tmp_q_num += points[j][0]
    if tmp_point < g:
        tmp_q_num += min_q(complete_flg, g-tmp_point)
    if mn>tmp_q_num:
        mn = tmp_q_num

print(int(mn))

Solution (Python):
import math

D,G = map(int, input().split())
l=[list(map(int,input().split())) for i in range(D)]
lst=[[(i+1)*100]*(l[i][0]-1) + [(i+1)*100 + l[i][1]] for i in range(len(l))]
ans = 100*D
dis = 100000*D
for i in range(1<<D):
    point,num,maxp=0,0,0
    for j in range(D):
        if (i>>j)&1:
            num+=len(lst[j])
            point+=sum(lst[j])
        else:
            maxp=j
    if point + (maxp+1)*100*(len(lst[maxp])-1) >= G:
        mq = max(0,math.ceil((G-point)/((maxp+1)*100)))
        ans = min(ans, num+mq)
print(int(ans))

Solution (Python):
D,G=map(int,input().split())
p=[0]*D
c=[0]*D
ans=1000000000
for i in range(D):
    p[i],c[i]=map(int,input().split())
for i in range(1<<D):
    s=0
    cnt=0
    P=[0]*D
    for j in range(D):
        if ((i>>j)&1)==1:
            s+=c[j]+(j+1)*p[j]*100
            cnt+=p[j]
            P[j]=1
    m=-1
    for k in range(D):
        if m<0:
            if P[D-k-1]==0:
                m=D-k
        else:
            break
    if m>=0:
        for l in range(p[m-1]-1):
            if s<G:
                s+=m*100
                cnt+=1
    if s>=G and cnt<ans:
        ans=cnt
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    D, G = il()
    PC = iml(D)
    ans = 999999999

    for i in range(1 << D):
        count = 0
        score = 0
        for j in range(D):
            if i >> j & 1:
                score += PC[j][1]
                score += PC[j][0] * (j + 1) * 100
                count += PC[j][0]

        for j in range(D - 1, -1, -1):
            if i >> j & 1:
                continue
            if score >= G:
                break
            g = (j + 1) * 100
            gg = (G - score + g - 1) // g
            score += min(gg, PC[j][0]) * g
            count += min(gg, PC[j][0])
        ans = min(ans, count)
    return ans


if __name__ == "__main__":
    print(solve())

Solution (Python):
import math
d,g=map(int,input().split())
p=[]
p_=[]
c=[]
ans=float('inf')
for i in range(d):
    pi,ci=map(int,input().split())
    p.append(pi)
    p_.append(pi)
    c.append(ci)
for i in range(2**d):
    s_bit=[int(x) for x in list(format(i,'b'))]
    point=0
    number=0
    for j in range(len(s_bit)):
        point+=s_bit[len(s_bit)-1-j]*100*(j+1)*p[j]+s_bit[len(s_bit)-1-j]*c[j]
        number+=s_bit[len(s_bit)-1-j]*p[j]
        p_[j]=p[j]-p[j]*s_bit[len(s_bit)-1-j]
    if point>=g:
        ans=min(ans,number)
    else:
        remain=g-point
        for j in range(d):
            if 100*(j+1)*p_[j]>=remain:
                k=math.ceil(remain/(100*(j+1)))
                ans=min(ans,number+k)
print(ans)

Solution (Python):
d, g = list(map(int, input().split()))
spc = []
for s in range(100, d * 100 + 1, 100):
    p, c = list(map(int, input().split()))
    spc.append([s, p, c + s * p])

from itertools import product
ans = float('inf')
for comps in product(range(2), repeat=d):
    cnt = sum(p * x for (s, p, c), x in zip(spc, comps))
    scr = sum(c * x for (s, p, c), x in zip(spc, comps))
    if scr >= g:
        if cnt < ans:
            ans = cnt
        continue
    for (s, p, c), x in zip(spc, comps):
        if x or s * (p - 1) + scr < g:
            continue
        cnt += -((scr - g) // s)
        if cnt < ans:
            ans = cnt

print(ans)

Solution (Python):
d,g=map(int,input().split())
l=[list(map(int,input().split()))for _ in range(d)]
for i in range(d):
    s=l[i][0]*100*-~i
    l[i].append(s+l[i][1])
    l[i].append(s)
a=10**18
for i in range(1<<d):
    s=t=k=0
    for j in range(d):
        if (i>>j)&1:
            s+=l[j][2]
            t+=l[j][0]
        else:
            k=j
    if s+l[k][3]<g:continue
    if s<g:
        t+=-(-(g-s)//(100*-~k))
    a=min(a,t)
print(a)

Solution (Python):
d,g=map(int,input().split())
l=[list(map(int,input().split()))for _ in range(d)]
for i in range(d):
    s=l[i][0]*100*-~i
    l[i].append(s+l[i][1])
    l[i].append(s)
a=10**18
for i in range(1<<d):
    s=t=k=0
    for j in range(d):
        if (i>>j)&1:
            s+=l[j][2]
            t+=l[j][0]
        else:
            k=j
    if s+l[k][3]<g:continue
    if s<g:
        t+=-(-(g-s)//(100*-~k))
    a=min(a,t)
print(a)

Solution (Python):
D, G = map(int, input().split())
P = []
C = []
for i in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)


def bit_search(A):
    result = []
    for i in range(1 << len(A)):
        output = []
        for j in range(len(A)):
            if ((i >> j) & 1) == 1:
                output.append(A[j])
        result.append(output)

    return result


search_list = bit_search(list(range(D)))
ans = 10 ** 9
for complete_list in search_list:
    score = sum([100 * (i + 1) * P[i] + C[i] for i in complete_list])
    count = sum([P[i] for i in complete_list])
    if score >= G:
        ans = min(ans, count)
    else:
        j_max = max([i for i in range(D) if i not in complete_list])
        required = -(-(G - score) // (100 * (j_max + 1)))
        if required < P[j_max]:
            count += required
            ans = min(ans, count)
print(ans)

Solution (Python):


import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def calc(bits, P, C, G):
    total = 0
    cnt = 0
    p = P[:]
    i = 0
    while bits > 0:
        if bits % 2:
            total += p[i] * (i + 1) * 100 + C[i]
            cnt += p[i]
            p[i] = 0
        bits >>= 1
        i += 1
    if total >= G:
        return cnt

    for i in range(len(p)-1, -1, -1):
        if p[i] != 0: break
    need = math.ceil((G - total) / ((i + 1) * 100))
    if need <= p[i]:
        return cnt + need
    return float("inf")



def main():
    D, G = MI()
    P = [None] * D
    C = [None] * D
    for i in range(D):
        P[i], C[i] = MI()

    ans = sum(P)
    for bits in range(2 << (D-1)):
        ans = min(ans, calc(bits, P, C, G))
    return ans



if __name__ == "__main__":
    print(main())

Solution (Python):


import itertools
import math

D, G = map(int, input().split())
ps, cs = [], []
for _ in range(D):
    p, c = map(int, input().split())
    ps.append(p)
    cs.append(c)

cps = list(itertools.product([True, False], repeat=D))
cps.pop(0) 

ans = sum(ps)
for cp in cps:
    point, qs, maxp = 0, 0, 0
    for i in range(D):
        if cp[i]:
            point += (i + 1) * 100 * ps[i] + cs[i]
            qs += ps[i]
        else:
            maxp = i
    if point + (maxp + 1) * 100 * (ps[maxp] - 1) >= G:
        mq = max(0, math.ceil((G - point) / ((maxp + 1) * 100)))
        ans = min(ans, qs + mq)

print(ans)

Solution (Python):
D,G = list(map(int,input().split()))
P = []
C = []

for i in range(D):
    p,c = list(map(int,input().split()))
    P.append(p)
    C.append(c)

ans = 10000

for c in range(2**D):
    score = 0
    solved = 0
    remain = []
    for i,b in enumerate(format(c,'b').zfill(D)):
        if b == '1':
            score += P[i]*100*(i+1) + C[i]
            solved += P[i]
        else:
            remain.append(i)
    if score < G:
        R = G - score
        j = remain[-1]
        if (P[j]-1)*(j+1)*100 < R:
            continue
        solved += -(-R//(100*(j+1)))
    ans = min(solved, ans)

print(ans)

Solution (Python):
D, G = map(int, input().split())
PC = [[int(pc) for pc in input().split()] for _ in range(D)]


def f(d, g):
    if 0 > d:
        return 100 ** 10
    n = min(g // (100 * (d + 1)), PC[d][0])
    s = n * 100 * (d + 1)
    if n == PC[d][0]:
        s += PC[d][1]
    if g > s:
        n += f(d - 1, g - s)
    return min(n, f(d - 1, g))


def main():
    print(f(D - 1, G))


main()

Solution (Python):
import math

def solve():
    [D,G] = [int(x) for x in input().split()]
    P = []
    C = []
    for _ in range(D):
        [p,g] = [int(x) for x in input().split()]
        P.append(p)
        C.append(g)

    LIM = 1 << D
    ans = 10**12  
    for bits in range(LIM):
        score = 0
        count = 0
        for i in range(D):
            maxi = -1
            if (bits >> i) & 1 == 1:
                
                
                score += P[i] * 100 * (i+1) + C[i]
                count += P[i]

        if G <= score:
            
            ans = min(ans, count)
            continue

        
        for i in range(D):
            if (bits >> i) & 1 != 1:
                n = (G-score) / ((i+1)*100)
                
                if n >= P[i]:
                    continue

                n = int(math.ceil(n))
                
                ans = min(ans, count + n)
    
    return ans


print(solve())

Solution (Python):
d, g = map(int, input().split())
pc = [0] + [[int(i) for i in input().split()] for i in range(d)]

def dfs(g, i):
    if i == 0:
        return 10 ** 12
    
    n = min(g // (100 * i), pc[i][0])
    score = n * 100 * i
    
    if n == pc[i][0]:
        score += pc[i][1]
        
    if g > score:
        n += dfs(g - score, i - 1)
        
    return min(n, dfs(g, i - 1))

print(dfs(g, d))

Solution (Python):
d, g = map(int, input().split())
pc = [0] + [[int(i) for i in input().split()] for i in range(d)]

def dfs(g, i):
    if i == 0:
        return 10 ** 12
    n = min(g // (100 * i), pc[i][0])
    score = 100 * i * n
    if n == pc[i][0]:
        score += pc[i][1]
    if g > score:
        n += dfs(g - score, i - 1)
    return min(n, dfs(g , i - 1))

print(dfs(g, d))

Solution (Python):
D, G = map(int, input().split())
p = []
c = []
PC = [0] + [list(map(int, input().split())) for _ in range(D)]
 
def dfs(G, i):
    if i == 0:
        return 10**12
    n = min(G // (100 * i), PC[i][0])
    tmp = n*100*i
    if n == PC[i][0]:
        tmp += PC[i][1]
    if tmp < G:
        n += dfs(G-tmp, i-1)
    return min(n, dfs(G, i-1))
 
print(dfs(G, D))

Solution (Python):
d,g = map(int,input().split())
info = [list(map(int,input().split())) for i in range(d)]

complete=[None]*d
for i in range(d):
  complete[i] = info[i][0]*(100*i+100) + info[i][1]
  

ans = 1000

for i in range(2**(d)):
  bin_i = str("0"*(d+2-len(bin(i)))+str(bin(i))[2:])
  
  
  summation=0
  count=0
  index_0=-1
  
  for j in range(d):
    if bin_i[j]=="1":
      summation += complete[j]
      count +=info[j][0]
    else:
      index_0 = j
      
  if summation >= g:
    ans = min(ans,count)
  elif summation < g:
    tmp_g = g
    for j in range(info[index_0][0]):
      tmp_g = tmp_g-100*(index_0+1)
      count +=1
      if summation >= tmp_g:
        ans = min(ans,count)
        break
  
  
print(ans)

Solution (Python):

import math

def main():
    na = list(map(int, input().split()))
    D, G = na[0], na[1]
    p = []
    c = []
    ts = []
    for i in range(D):
        na = list(map(int, input().split()))
        p.append(na[0])
        c.append(na[1])
        ts.append(100 * (i + 1) * na[0] + na[1])

    max_i = 2 ** D
    min_q = 1000
    for i in range(max_i):
        q = 0
        s = 0
        max_uc = -1
        for j in range(D):
            if i & (2 ** j) != 0:
                q += p[j]
                s += ts[j]
            else:
                max_uc = j
        if G <= s:
            min_q = min(min_q, q)
        elif G <= s + 100 * (max_uc + 1) * (p[max_uc] - 1):
            min_q = min(min_q, q + math.ceil((G - s) / 100 / (max_uc + 1)))

    print(min_q)


if __name__ == '__main__':
    main()

Solution (Python):


import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()



def ceil(n, m):
    return -(-n//m)


d, g = LI()
contest = [LI() for _ in range(d)]

ans = INF


for bit in range(1 << d):
    score = 0
    cnt = 0
    remain_max = -1

    
    for i in range(d):
        if bit >> i & 1:
            score += contest[i][0] * (i + 1) * 100 + contest[i][1]
            cnt += contest[i][0]
            continue
        
        remain_max = i

    if score >= g:
        ans = min(ans, cnt)
        continue

    need = ceil((g - score) // 100, remain_max + 1)

    if need >= contest[remain_max][0]:
        continue

    ans = min(ans, cnt + need)

print(ans)

Solution (Python):
import math as m
D,G = map(int, input().split())
info = [list(map(int, input().split())) for i in range(D)]
def bfs(list_hoge=[[0,[]]],depth=0):
    queue = []
    for e in list_hoge:
        for b in [0,1]:
            if b == 0:
                score = e[0]
                copy = e[1][:]
                queue.append([score,copy])
            elif b == 1:
                score = e[0] + 100*(depth+1)*info[depth][0] + info[depth][1]
                copy = e[1][:]
                copy.append(depth)
                queue.append([score,copy])
    list_hoge = queue[:]
    if depth == len(info)-1:
        return list_hoge
    return bfs(list_hoge,depth+1)
res = bfs()
ans = float("inf")
for e in res:
    solved = 0
    for i in range(len(e[1])):
        solved += info[e[1][i]][0]
    if e[0] >= G:
        if solved < ans:
            ans = solved
        continue
    for i in range(D-1,-1,-1):
        if not i in e[1]:
            nec = G-e[0]
            haiten = 100*(i+1)
            add_solve = m.ceil(nec/haiten)
            total_solved = solved + m.ceil(nec/haiten)
            if add_solve >= info[i][0]:
                break
            if total_solved < ans:
                ans = total_solved
print(ans)

Solution (Python):
D, G = map(int, input().split())
cp = [list(map(int, input().split())) for i in range(D)]
ans = []

for j in range(2 ** D):
    check = 0
    con = 0
    rest = -1
    for i in range(D):
        p, c = cp[i]
        if j & (2**i):
            check += p * 100 * (i + 1) + c
            con += p
        else:
            rest = i

    if G <= check:
        ans.append(con)
    else:
        p1 = 100 * (rest + 1)
        pn = cp[rest][0] - 1
        for i in range(pn + 1):
            if G <= check + p1 * i:
                ans.append(con + i)
                break
print(min(ans))

Solution (Python):


from itertools import product
from math import ceil

INF = 99999999999999999999999999

def main():
    d, g = map(int, input().split())
    pcs = []
    for i in range(d):
        p, c = map(int, input().split())
        pcs.append((p, c))
    comps = product((False, True), repeat=d)
    mi = INF
    for comp in comps:
        so = minimum_solution_g(d, g, pcs, comp)
        mi = min(mi, so)
    print(mi)

def minimum_solution_g(d, g, pcs, comp):
    score = 0
    used = 0
    avail = []
    for i in range(d):
        if comp[i]:
            score += pcs[i][1] + (i + 1) * 100 * pcs[i][0]
            used += pcs[i][0]
            avail.append(0)
        else:
            avail.append(pcs[i][0] - 1)
    for i in reversed(range(d)):
        if score >= g:
            break
        score_one = (i + 1) * 100
        use = min(avail[i], int(ceil((g - score) / score_one)))
        assert use >= 0
        used += use
        score += score_one * use
    if score >= g:
        return used
    else:
        return INF

main()

Solution (Python):
D,G=(int(i) for i in input().split())
p,c=[],[]

for i in range(D):
    tmpp,tmpd = (int(i) for i in input().split())
    p.append(tmpp)
    c.append(tmpd)



comp = [100*(i+1)*p[i]+c[i] for i in range(D)]



ans = sum(p)



b=[0]*D
while True:
    
    score = sum([comp[i]*b[i] for i in range(D)])
    
    probCount = sum([p[i]*b[i] for i in range(D)])

    
    
    hi = 'None' 
    for i in range(D):
        k = D-i-1
        if b[k]==0:
            hi = k
            break
    
    if hi != 'None':
        for i in range(p[k]):
            if score >=G:
                break
            else:
                score += 100*(hi+1)
                probCount += 1

    
    if score>=G and ans > probCount:
        ans = probCount

    
    if all(b):
        break
    
    
    for i in range(D):
        if b[i]==0:
            for j in range(i):
                b[j]=0
            b[i]=1
            break
    
print(ans)

Solution (Python):
d, g = map(int, input().split())
p = []
c = []
ans = 1000000

for i in range(d):
    a, b = map(int, input().split())
    p.append(a)
    c.append(b)

for i in range(1 << d):
    select = []
    for j in range(d):
        if ((i >> j) & 1) == 1:
            select.append(j)

    tans = 0
    npoint = g

    for j in select:
        tans += p[j]
        npoint -= c[j]
        npoint -= (j + 1) * 100 * p[j]

    slv = 0
    slvj = 0
    
    for j in range(d - 1, -1, -1):
        if j in select:
            continue
        slvj = j
        break

    while npoint > 0:  
        
        slv += 1
        npoint -= (slvj + 1) * 100

    
    
    if slv > p[slvj]:
        continue

    tans += slv
    ans = min(ans, tans)
print(ans)