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):









import math
import sys
input = sys.stdin.readline

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)

INF = 10**15


def F(i, n, GetPoint):
    if i == D:
        if GetPoint >= G:
            return n, GetPoint
        else:
            return INF, INF

    PerPoint = (i+1)*100

    if GetPoint < G:
        ANS = INF, INF
        
        N, GP = F(i+1, n+P[i], GetPoint+PerPoint*P[i] + C[i])
        if N < ANS[0]:
            ANS = N, GP
        
        N, GP = F(i+1, n, GetPoint)
        if N < ANS[0]:
            ANS = N, GP

        
        
        PupperAll = sum([(j+1)*100*P[j] + C[j] for j in range(i+1, D)])
        rN = math.ceil((G - GetPoint - PupperAll)/PerPoint)
        if 0 < rN < P[i]:
            GP = GetPoint + PerPoint*rN + PupperAll
            N = n + rN + sum(P[i+1:])
            if N < ANS[0]:
                ANS = N, GP

        return ANS
    else:
        return n, GetPoint


print(F(0, 0, 0)[0])

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

pc = pc[::-1]

ans = float('inf')
for i in range(2**d):
  total = 0
  cnt = 0
  for j in range(d):
    if (i>>j) & 1:
      total += 100*(d-j)*pc[j][0] + pc[j][1]
      cnt += pc[j][0]
    if total >= g:
      ans = min(ans, cnt)
      continue
  for j in range(d):
    if (i>>j) & 1 == False:
      for k in range(pc[j][0]):
        total += 100*(d-j)
        cnt += 1
        if total >= g:
          ans = min(ans, cnt)
          break
      break
      
print(ans)

Solution (Python):
import sys
from collections import defaultdict, deque, Counter
import math
 

from bisect import bisect_left, bisect_right

 

 

input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)
 
def search(pros,tgt,g,d):
    tmp = 0
    cnt = 0
    rest = []
    for i in range(d):
        if tgt % 2 == 1:
            tmp += 100 * (i+1) * pros[i][0] + pros[i][1]
            cnt += pros[i][0]
        else:
            rest.append((i+1,pros[i][0]-1))
        tgt //= 2
    
    if tmp >= g:
        return cnt
    for ap, ac in rest[::-1]:
        if tmp + 100 * ap * ac >= g:
            cnt += math.ceil((g - tmp)/(100 * ap))
            return cnt
        else:
            cnt += ac
            tmp += 100 * ac * ap

    return INF

def main():
    d,g = getList()
    pros = []
    for i in range(d):
        pros.append(getList())
    ans = INF
    tgt = 2 ** d
    for i in range(tgt):
        tmp = search(pros, i,g, d)
        
        if tmp < ans:
            ans = tmp

    print(ans)
    return


 
if __name__ == "__main__":
    main()

Solution (Python):
d,g = map(int,input().split())
p = [0] * d
c = [0] * d
for i in range(d):
    p[i],c[i] = map(int,input().split())
ans_num = float('inf')
for i in range(2 ** d):
    score_li = list(range(1,d+1))
    ans_li = []
    ans_n = 0
    for j in range(d):
        if i >> j & 1:
            ans_li.append(p[j]*score_li[j]*100+c[j])
            score_li[j] = -1
            ans_n += p[j]
    if sum(ans_li) < g:
        s = sum(ans_li)
        score_li.sort(reverse=True)
        for k in score_li:
            for l in range(p[k-1]):
                s += k*100
                ans_n += 1
                if s >= g:
                    ans_num = min(ans_n, ans_num)
    else:
        ans_num = min(ans_n, ans_num)
print(ans_num)

Solution (Python):
from collections import deque
import sys
input = sys.stdin.readline
D, G = map(int, input().split())
solved = [0]*1001
for score in range(100, D*100+1, 100):
    p, c = map(int, input().split())
    q = deque()

    bkp = solved.copy()
    for j, s in enumerate(solved):
        val = s - j*score
        while q and q[-1][1] < val:
            q.pop()
        q.append((j, val))

        k, vmax = q[0]
        solved[j] = max(solved[j], vmax+j*score)
        if k == j-p:
            q.popleft()
        if j-p >= 0:
            solved[j] = max(solved[j], bkp[j-p]+p*score+c)

for i, s in enumerate(solved):
    if s >= G:
        print(i)
        exit()

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
d,g = readInts()
P = []
C = []
res = float('inf')
for i in range(d):
    p,c = readInts()
    P.append(p)
    C.append(c)
for bit in range(1 << d):
    SUM = 0
    NUM = 0
    for i in range(d):
        if bit & (1 << i):
            SUM += 100 * (i + 1) * P[i] + C[i]
            NUM += P[i]
    if SUM >= g:
        res = min(res,NUM)
    else:
        for i in range(d-1,-1,-1):
            if bit & (1 << i):
                continue
            else:
                for j in range(P[i]):
                    if SUM >= g:
                        break
                    SUM += 100 * (i+1)
                    NUM += 1
        res = min(res,NUM)
print(res)

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

PC.reverse()

ans = 10**18
for i in range(2**d):
    temp = 0
    cnt = 0
    flag = True
    for j in range(d):
        if (i >> j) & 1:
            temp += 100*(d-j)*PC[j][0]+PC[j][1]
            cnt += PC[j][0]
    for j in range(d):
        if not ((i >> j) & 1):
            t = 100*(d-j)
            r = g-temp
            if r > 0:
                q = (r+t-1)//t
                if q < PC[j][0]:
                    temp += 100*(d-j)*q
                    cnt += q
                else:
                    flag = False
    if flag and temp >= g:
        ans = min(ans, cnt)
print(ans)

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

ans = 9999
for b in range(1<<D):
    sc = pr = 0
    for i,(p,c) in enumerate(PC):
        if b&(1<<i):
            sc += c + (i+1)*100*p
            pr += p
    if sc >= G:
        ans = min(ans, pr)
        continue
    remsc = G - sc
    for i,(p,_) in reversed(list(enumerate(PC))):
        if b&(1<<i): continue
        for j in range(p):
            remsc -= (i+1)*100
            pr += 1
            if remsc <= 0:
                ans = min(ans, pr)
                break
        else:
            continue
        break
    if remsc <= 0:
        ans = min(ans, pr)
print(ans)

Solution (Python):
from itertools import groupby, accumulate, product, permutations, combinations
def solve():
  ans = 2000
  D, G = map(int, input().split())
  P = [0]*D
  C = [0]*D
  for i in range(D):
    P[i],C[i] = map(int, input().split())
  for p in product([0,1],repeat=D):
    if sum(p)<D:
      for i in range(D-1,-1,-1):
        if p[i]==0:
          maxi = i
          break
    cnt = 0
    score = 0
    for i in range(D):
      if p[i]==1:
        score += (i+1)*100*P[i]+C[i]
        cnt += P[i]  
    if -(-(G-score)//(100*(maxi+1)))>=P[maxi]:
      continue
    if G>score:
      cnt += -(-(G-score)//(100*(maxi+1)))
    ans = min(ans,cnt)
  return ans
print(solve())

Solution (Python):
d, g = map(int, input().split())
pc = []
for _ in range(d):
    p, c = map(int, input().split())
    pc.append((p, c))
ans = 1000
for i in range(2**d):
    score = 0
    k = 0
    for j in range(d):
        if i>>j&1:
            score += pc[j][0]*100*(j+1) + pc[j][1]
            k += pc[j][0]
    if score>=g:
        ans = min(ans, k)
        continue
    for j in range(d-1, -1, -1):
        if i>>j&1:
            continue
        if score+(pc[j][0]-1)*100*(j+1)<g:
            score += (pc[j][0]-1)*100*(j+1)
            k += pc[j][0]-1
            continue
        k += (g-score+100*(j+1)-1)//(100*(j+1))
        ans = min(ans, k)
        break
print(ans)

Solution (Python):
D, G = map(int, input().split())
p = []
c = []
for _ in range(D):
    p_i, c_i = map(int, input().split())
    p.append(p_i)
    c.append(c_i)
answer = 10000000

for bit in range(2 ** D):
    s, num, rest_max = 0, 0, 0
    for i in range(D):
        if bit & (1 << i):
            s += 100 * (i + 1) * p[i] + c[i]
            num += p[i]
        else:
            rest_max = i
    if s < G:
        s1 = 100 * (rest_max + 1)
        if (G - s) % s1 == 0:
            need = (G - s) // s1
        else:
            need = (G - s) // s1 + 1
        if need >= p[rest_max]:
            continue
        num += need
    answer = min(answer, num)
print(answer)

Solution (Python):
import itertools

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

ans = 10000000

pick_num = []

for i in range(D):
    pick_num.append(i)

for i in range(0,D+1):
    for v in itertools.combinations(pick_num, i):      
        tmp_point = 0
        tmp_count = 0
        for j in v:
            tmp_point += ab[j][0]*(j+1)*100+ab[j][1]
            tmp_count += ab[j][0]
        if tmp_point < G:
            nokori = G-tmp_point
            for k in range(D-1, -1,-1):
                if k not in v:
                    if nokori%(100*(k+1)) == 0:
                        if nokori//(100*(k+1)) < ab[k][0]:
                            tmp_count += nokori//(100*(k+1))
                            tmp_point += nokori
                    else:
                        if nokori//(100*(k+1))+1 < ab[k][0]:
                            tmp_count += nokori//(100*(k+1))+1
                            tmp_point += nokori
                    break
        if G <= tmp_point:
            ans = min(ans, tmp_count)
print(ans)

Solution (Python):

d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]
all_sum = []
for bit in range(1<<d):
    s = 0
    a = 0
    rest = []
    for i in range(d):
        if bit & (1<<i):
            s += pc[i][0]*100*(i+1) + pc[i][1]
            a += pc[i][0]
        else :
            rest.append(i)
    
    if s >= g :
        all_sum.append(a)
    else :
        k = max(rest)
        diff = g - s
        for j in range(pc[k][0]):
            if j*(k+1)*100 >= diff:
                all_sum.append(a+j)
print(min(all_sum))

Solution (Python):
d,g = map(int,input().split(" "))
li=[]
for x in range(d):
  li.append(list(map(int,input().split(" "))))

sum=[]
for i in range(2**(d)):
  s=0
  a=0
  z=[]
  for j in range(d):
    if i >> j & 1:
      s += li[j][0]*100*(j+1) + li[j][1]
      a += li[j][0]
    else:
      z.append(j)

  if s >= g:
    sum.append(a)
  else:
    k = max(z)
    h = g-s
    for l in range(li[k][0]):
      if l*(k+1)*100 >= h:
        sum.append(a+l)
        
print(min(sum))

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

n = 2 ** d
result = 100 * 10

for i in range(n):
  bin_n = bin(i)[2:]
  bin_n = '0' * (d - len(bin_n)) + bin_n
  max_address = -1
  total = 0
  num_of_question = 0

  for j in range(d):
    if bin_n[j] == '1':
      total += (j+1) * 100 * pc[j][0] + pc[j][1]
      num_of_question += pc[j][0]
    
    else:
      max_address = j
  
  if total >= g:
    result = min(result, num_of_question)
  
  else:
    for _ in range(pc[max_address][0]):
      num_of_question += 1
      total += (max_address+1) * 100
      if total >= g:
        result = min(result, num_of_question)
        break

print(result)

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

score_table = []
for i in range(1, D+1):
    p, c = [int(n) for n in input().split()]
    score_table.append([i*100, p, c])

min_count = sum([l[1] for l in score_table])


for bit in range(1<<D):
    score = 0
    count = 0

    for i in range(D):
        if bit & (1<<i):
            score += score_table[i][0] * score_table[i][1] + score_table[i][2]
            count += score_table[i][1]
    
    if score >= G:
        min_count = min(min_count, count)
    else:
        additional = []
        for j in range(D):
            if not bit & (1<<j):
                additional.append(score_table[j])
        
        additional_ = sorted(additional, key=lambda x:x[0], reverse=True)
        
        
        
        
        
        

        

        for k in range(additional_[0][1]-1):
            score += additional_[0][0]
            count += 1
            if score >= G:
                min_count = min(min_count, count)

print(min_count)

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

score_table = []
for i in range(1, D+1):
    p, c = [int(n) for n in input().split()]
    score_table.append([i*100, p, c])

min_count = sum([l[1] for l in score_table])


for bit in range(1<<D):
    score = 0
    count = 0

    for i in range(D):
        if bit & (1<<i):
            score += score_table[i][0] * score_table[i][1] + score_table[i][2]
            count += score_table[i][1]
    
    if score >= G:
        min_count = min(min_count, count)
    else:
        additional = []
        for j in range(D):
            if not bit & (1<<j):
                additional.append(score_table[j])
        
        additional_ = sorted(additional, key=lambda x:x[0], reverse=True)
        
        
        
        
        
        

        add_score = additional_[0]

        for k in range(add_score[1]-1):
            score += add_score[0]
            count += 1
            if score >= G:
                min_count = min(min_count, count)

print(min_count)

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

 
 
for i in range(2**D) :
    score=0
    solve=0
    needproblem=0
    for j in range(D) :                  
        if (i>>j) & 1 :
            score+=P[j]*100*(j+1)+C[j]
            solve+=P[j]
        if (~i>>j) & 1 :                  
            needproblem=j+1
    if score>=G :
        point=min(point,solve)
 


 
    elif score<G :                
        rest=G-score
        sum=(P[needproblem-1]-1)*needproblem*100
        if rest>sum :            
            continue
        elif rest<=sum :
            resolve=solve+(rest//(needproblem*100)+(rest%(needproblem*100)>0))
            point=min(point,resolve)
 
print(point)

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

 
 
for i in range(2**D) :
    score=0
    solve=0
    needproblem=0
    for j in range(D) :                  
        if (i>>j) & 1 :
            score+=P[j]*100*(j+1)+C[j]
            solve+=P[j]
        if (~i>>j) & 1 :                  
            needproblem=j+1
    if score>=G :
        point=min(point,solve)
 


 
    elif score<G :                
        rest=G-score
        sum=(P[needproblem-1]-1)*needproblem*100
        if rest>sum :            
            continue
        elif rest<=sum :
            resolve=solve+(rest//(needproblem*100)+(rest%(needproblem*100)>0))
            point=min(point,resolve)
 
print(point)

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

 
 
for i in range(2**D) :
    score=0
    solve=0
    needproblem=0
    for j in range(D) :                  
        if (i>>j) & 1 :
            score+=P[j]*100*(j+1)+C[j]
            solve+=P[j]
    if score>=G :
        point=min(point,solve)
 


    elif score<G :
        rest=G-score
        for j in range(D) :
            if (~i>>D-j-1) & 1 :
                needproblem=D-j
                sum=needproblem*100*(P[needproblem-1]-1)
                if rest>sum :            
                    rest-=sum
                    solve+=P[needproblem-1]-1
                elif rest<=sum :
                    solve+=(rest//(needproblem*100)+(rest%(needproblem*100)>0))
                    rest=0
            if rest<=0 and D*100>solve :
                point=min(point,solve)               
 
print(point)

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

 
scores=[None]*D
for i in range(D):
  p,c=map(int,input().split())
  
  scores[i]=[(i+1)*100,p,c,((i+1)*100)*p+c]
 

scores=sorted(scores,key=lambda x:x[0])[::-1]
 

ans=D*100
for i in range(2**D):
  total=0
  solve=0
  for j in range(D):
    if (i>>j)&1:
      
      total+=scores[j][3]
      solve+=scores[j][1]
  if total>=G:
    if ans>solve:
      ans=solve
    continue
  rest=G-total
  for j in range(D):
    if (i>>j)&1==0:
      point=scores[j][0]
      num=scores[j][1]-1 
      if point*num<rest:
        rest-=point*num
        solve+=num
      else:
        solve+=(rest//point+(rest%point>0))
        rest=0
    if rest<=0 and ans>solve:
      ans=solve
  
print(ans)

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

res = 1000
for i in range(1 << D):
    b = format(i, '01000b')[::-1]
    s = 0
    cnt = 0
    k = 0
    for j in range(D):
        if b[j] == '1':
            s += 100 * (j + 1) * P[j] + C[j]
            cnt += P[j]
        else:
            k = j
    if s >= G:
        res = min(res, cnt)
    else:
        for l in range(P[k] - 1):
            s += 100 * (k + 1)
            cnt += 1
            if s >= G:
                res = min(res, cnt)
                break
print(res)

Solution (Python):
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(D)]
min_solve_num = 1000
for i in range(1, 2 ** D):
    score = 0
    tmp_solve_num = 0
    for j in range(D):
        if (i >> j) & 1:
            score += pc[j][0] * (j + 1) * 100 + pc[j][1]
            tmp_solve_num += pc[j][0]
    if score >= G and tmp_solve_num < min_solve_num:
        min_solve_num = tmp_solve_num
score = 0
tmp_solve_num = 0
for i in range(D - 1, -1, -1):
    num = pc[i][0]
    for j in range(num):
        score += (i + 1) * 100
        tmp_solve_num += 1
        if j == num - 1:
            score += pc[i][1]
        if score >= G:
            break
    else:
        continue
    break
if tmp_solve_num < min_solve_num:
    min_solve_num = tmp_solve_num
print(min_solve_num)

Solution (Python):
import math

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

ans = float('inf')
for i in range(2 ** d):
    sum = 0
    count = 0
    s = set(k for k in range(1, d + 1))
    for j in range(d):
        if (i >> j) & 1 == 1:
            sum += l[j][0] * (j + 1) * 100 + l[j][1]
            count += l[j][0]
            s.discard(j + 1)
    if sum < g:
        t = max(s)
        n = min(l[t - 1][0] - 1, math.ceil((g - sum) / (t * 100)))
        count += n
        sum += n * t * 100
    if sum >= g:
        ans = min(ans, count)
print(ans)

Solution (Python):

def solve():
    d = 0
    c = 0
    for i in range(D):
        d += p[i][0]
    dp = [[0]*(d+1) for i in range(D)]
    for i in range(D):
        for j in range(p[i][0]+1):
            if i == 0:
                if j == p[i][0]:
                    dp[i][j] += p[i][1]
                dp[i][j] += 100*j
            else:
                for k in range(c+1):
                    if j == p[i][0]:
                        dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*j*(i+1)+p[i][1])
                    else:
                        dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*j*(i+1))
        c += p[i][0]
    for i in range(d+1):
        if dp[D-1][i]>=G:
            print(i)
            break    
    
if __name__=="__main__":
    D,G = list(map(int, input().split()))
    p = [list(map(int, input().split())) for _ in range(D)]
    solve()

Solution (Python):
import sys
import itertools
from math import ceil

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    D, G = in_nn()
    p = [0] * D
    c = [0] * D
    for i in range(D):
        a, b = in_nn()
        p[i] = a
        c[i] = b

    comb = itertools.product([0, 1], repeat=D)
    ans = 10**9 + 7

    for com in comb:
        score = 0
        prob = 0
        for i, x in enumerate(com):
            if x == 1:
                prob += p[i]
                score += c[i] + p[i] * 100 * (i + 1)

        for i in range(D - 1, -1, -1):
            if score >= G:
                break
            if com[i] == 0:
                pt = ceil((G - score) / (100 * (i + 1)))
                pt = min(pt, p[i] - 1)
                score += pt * 100 * (i + 1)
                prob += pt

        if score >= G:
            ans = min(ans, prob)

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    D, G = in_nn()
    p = [0] * D
    c = [0] * D
    for i in range(D):
        a, b = in_nn()
        p[i] = a
        c[i] = b

    comb = itertools.product([0, 1], repeat=D)
    ans = 10**9 + 7

    for com in comb:
        score = 0
        prob = 0
        for i, x in enumerate(com):
            if x == 1:
                prob += p[i]
                score += c[i] + p[i] * 100 * (i + 1)

        for i in range(D - 1, -1, -1):
            if score >= G:
                break
            if com[i] == 0:
                pt = int((G - score) / (100 * (i + 1)) + 0.9999)
                pt = min(pt, p[i] - 1)
                score += pt * 100 * (i + 1)
                prob += pt

        if score >= G:
            ans = min(ans, prob)

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def dfs(i, sum, count, nokori):
    global ans
    if i == d:
        
        if sum < g:
            use = max(nokori)
            
            n = min(pc[use - 1][0], -(-(g - sum) // (use * 100))) 
            count += n
            sum += n * use * 100
        if sum >= g:
            ans = min(ans, count)
    else:
        
        dfs(i + 1, sum, count, nokori)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], nokori - {i + 1})
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]
ans = float("inf")
dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)

Solution (Python):
import math

D, G = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(D)]

ans = 100000000
for bit in range(1 << D):
    s = 0
    ans_ = 0
    li = 0
    for i in range(D):
        if bit & (1 << i):
            s += (i+1) * 100 * pc[i][0] + pc[i][1] 
            ans_ += pc[i][0]
        else:
          li = i  
    if s < G:
        lv = 100 * (li + 1)
        need = int(math.ceil((G - s) / lv))
        if pc[li][0] < need:
            continue
        ans_ += need
    ans = min(ans, ans_)

print(int(ans))

Solution (Python):

D, G = map(int, input().split(' '))
p_c_pairs = [((i+1) * 100, list(map(int, input().split(' ')))) for i in range(D)]

import math
ans = float('inf')
p_c_pairs.sort(key=lambda x: -x[0])
for d in range(1<<D):
    

    cnt = 0
    g = G
    for i in range(D):
        if 1 & (d >> i):
            score, (p, c) = p_c_pairs[i]
            g -= score * p + c
            cnt += p

    if g > 0:
        for i in range(D):
            if not (1 & (d >> i)):
                score, (p, c) = p_c_pairs[i]
                n = min(p, int(math.ceil(g/score)))
                g -= score * n
                cnt += n
                break

    
    if g <= 0:
        ans = min(ans, cnt)

print(ans)

Solution (Python):
d,g=map(int,input().split())
L=[]

for i in range(d):
    L.append([int(i) for i in input().split()])

C=[L[i][0]*(i+1)*100 for i in range(d)]

import itertools
itr=list(itertools.product([0,1],repeat=d))

def calc(key,g):
    cnt=0
    sco=0
    for i in range(d):
        if key[i]==1:
            cnt+=L[i][0]
            sco+=L[i][0]*(i+1)*100+L[i][1]
    rem=g-sco
    
    if rem<=0:
        return cnt
    for i in range(d-1,-1,-1):
        if key[i]==0:
            if rem-L[i][0]*(i+1)*100<=0:
                return cnt+((rem-1)//((i+1)*100))+1
            else:
                rem-=L[i][0]*(i+1)*100
                cnt+=L[i][0]
    return 10**7

ans=10**7
for key in itr:
    
    ans=min(calc(key,g),ans)
print(ans)

Solution (Python):
d,g = map(int,input().split())
p = []
c = []
for i in range(d):
    x,y = map(int,input().split())
    p.append(x)
    c.append(y)

ans = 10**3+1
for i in range(2**d):
    tmp = 0
    tmp_ans = 0
    t = [0]*d
    for j in range(d):
        if (i>>j)&1:
            tmp += 100*(j+1)*p[j] + c[j]
            tmp_ans += p[j]
            t[j] = 1
    if tmp < g:
        for k in range(d-1,-1,-1):
            if t[k] == 0:
                if tmp+100*(k+1)*(p[k]-1) < g:
                    tmp_ans += 10**3+1
                else:
                    if (g-tmp)%(100*(k+1)) == 0:
                        tmp_ans += (g-tmp)//(100*(k+1))
                    else:
                        tmp_ans += (g-tmp)//(100*(k+1))+1
                break
    ans = min(tmp_ans,ans)

print(ans)

Solution (Python):


D, G = map(int, input().split())
P = [tuple(map(int, input().split())) for _ in range(D)]

ans = 10**18
for i in range(1<<D):
    tmp = 0
    cnt = 0
    for j in range(D):
        if (i>>j)&1:
            p, c = P[j]
            tmp += p * (j+1) * 100 + c
            cnt += p
    if tmp >= G:
        ans = min(ans, cnt)
    else:
        xor_i = i^((1<<D)-1)
        for k in range(D)[::-1]:
            if (xor_i)>>k&1:
                p, c = P[k]
                for _ in range(p):
                    tmp += (k+1) * 100
                    cnt += 1
                    if tmp >= G:
                        ans = min(ans, cnt)
                        break
                else:
                    break
                break

print(ans)

Solution (Python):


from itertools import product
from itertools import compress


D, G = map(int, input().split())
data = []
for _ in range(D):
    data.append(tuple(map(int, input().split())))

res = []
for bit in product(*((0,1),)*D):
    S = 0
    cnt = 0
    for i, a in enumerate(data):
        p, c = a
        S += (100*(i+1)*p + c)*(bit[i]==0)
        cnt += p*(bit[i]==0)
    if S >= G:
        res.append(cnt)
    else:
        for i, d in enumerate(reversed(bit)):
            if d:
                break
        for k in range(1,data[D-i-1][0]+1):
            cnt += 1
            if S + 100*(D-i)*k >= G:
                res.append(cnt)
                break


print(min(res))

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


ans = float("inf")


def dfs(i, sum, count, nokori):
    global ans
    if i == d:
        
        if sum < g:
            use = max(nokori)
            
            n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
            count += n
            sum += n * use * 100

        if sum >= g:
            ans = min(ans, count)
    else:
        
        dfs(i + 1, sum, count, nokori)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 +
            pc[i][1], count + pc[i][0], nokori - {i + 1})


dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)

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

ans = 10000
for i in range(2**D):
    count = 0
    no = []
    s = 0
    for j in range(D):
        if (i >> j) & 1:
            count += pc[j][0]
            s += 100*(j+1)*pc[j][0] + pc[j][1]
        else:
            no.append(j)
    if s >= G:
        ans = min(ans, count)
    else:
        for j in no:
            t = s + 100*(j+1)*(pc[j][0] -1)
            if t >= G:
                ans = min(ans, count + math.ceil((G-s) /(100*(j+1))))
print(ans)

Solution (Python):
D,G=map(int,input().split())
p=[list(map(int,input().split())) for _ in range(D)]
c=0
d=0
for i in range(D):
  d+=p[i][0]
dp=[[0]*(d+1)for i in range(D)]
for i in range(D):
  for j in range(p[i][0]+1):
    if i==0:
      if j==p[i][0]:
        dp[i][j]+=p[i][1]
      dp[i][j]+=100*j
    else:
      for k in range(c+1):
        if j==p[i][0]:
          dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*j*(i+1)+p[i][1])
        else:
          dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*j*(i+1))
  c+=p[i][0]
for i in range(d+1):
  if dp[D-1][i]>=G:
    print(i)
    break