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


""" ビット全検索をちゃんと使ってみる版2 """

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


class ScoreSet:
    def __init__(self, times, score):
        self.times = times
        self.score = score


class ScoreSetSum:
    def __init__(self, times, score, bool_list):
        self.times = times
        self.score = score
        self.bool_list = bool_list


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


scoreSetSumList = []
for i in range(1<<D):
    times_tmp = 0
    score_tmp = 0
    bool_list = []
    for j in range(D):
        if 1 & i>>j == 1:
            times_tmp += scoreSetList[j].times
            score_tmp += scoreSetList[j].score
            bool_list.append(True)
        else:
            bool_list.append(False)
    scoreSetSumList.append(ScoreSetSum(times_tmp, score_tmp, bool_list))


ans = float("inf")
for scoreSetSum in scoreSetSumList:
    tmp = float("inf")
    
    if scoreSetSum.score >= G:
        tmp = scoreSetSum.times
    else:
        
        for i in range(D-1, -1, -1):
            if scoreSetSum.bool_list[i] == False:
                score = scoreSetSum.score
                times = scoreSetSum.times
                
                for j in range(scoreSetList[i].times):
                    score += 100*(i+1)
                    times += 1
                    
                    if score >= G:
                        tmp = times
                        break
                    
                break
    
    ans = min(ans, tmp)

print(ans)

Solution (Python):


""" ビット全検索をちゃんと使ってみる版 """

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


class ScoreSet:
    def __init__(self, times, score):
        self.times = times
        self.score = score


class ScoreSetSum:
    def __init__(self, times, score, bool_list):
        self.times = times
        self.score = score
        self.bool_list = bool_list


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





bool_lists = []
for i in range(1<<D):
    
    bool_lists.append([])
    for j in range(D):
        
        if 1 & i>>j == 1:
            bool_lists[i].append(True)
        else:
            bool_lists[i].append(False)


scoreSetSumList = []
for bool_list in bool_lists:
    times_tmp = 0
    score_tmp = 0
    for i in range(len(bool_list)):
        if bool_list[i]:
            times_tmp += scoreSetList[i].times
            score_tmp += scoreSetList[i].score
    scoreSetSumList.append(ScoreSetSum(times_tmp, score_tmp, bool_list))


ans = float("inf")
for scoreSetSum in scoreSetSumList:
    tmp = float("inf")
    
    if scoreSetSum.score >= G:
        tmp = scoreSetSum.times
    else:
        
        for i in range(D-1, -1, -1):
            if scoreSetSum.bool_list[i] == False:
                score = scoreSetSum.score
                times = scoreSetSum.times
                
                for j in range(scoreSetList[i].times):
                    score += 100*(i+1)
                    times += 1
                    
                    if score >= G:
                        tmp = times
                        break
                    
                break
    
    ans = min(ans, tmp)

print(ans)

Solution (Python):

from itertools import combinations

line = input().split(" ")
d = int(line[0])
g = int(line[1])

p = []
c = []
for _ in range(d):
    line = input().split(" ")
    p.append(int(line[0]))
    c.append(int(line[1]))

ret = 10000
for sel in range(0,d+1):
    for s in combinations(range(d),sel):
        score = 0
        num = 0
        for si in s:
            score += (si+1)*100*p[si] + c[si]
            num += p[si]
        if score>=g:
            if num<ret:
                ret = num
            continue

        r = set(range(d)) - set(s)
        if len(r)==0:
            continue

        si = max(r)
        for pi in range(p[si]):
            score += (si+1)*100
            num += 1
            if score>=g and num<ret:
                ret = num

print(ret)

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

p=[]
c=[]

for i in range(d):
    a,b=map(int,input().split())
    p.append(a)
    c.append(b)
    
sum=[]
for i in range(d):
    sum.append((i+1)*100*p[i]+c[i])


def ans(g,t):
    if t<=0:
        return 100000000000
    n=min(int(g/(100*t)),p[t-1])
    s=100*t*n
    
    if n==p[t-1]:
        s=sum[t-1]
    if g>s:
        n+=ans(g-s,t-1)
    
    return min(n,ans(g,t-1))

print(ans(g,d))

Solution (Python):
D, G = map(int, input().split())
S = [[0] for i in range(D + 1)]
B = [[0] for i in range(D + 1)]
sumP = 0
for i in range(D):
  p, c = map(int, input().split())
  S[i + 1] += [0] * (len(S[i]) + p - 1)
  B[i + 1] += [100 * (i + 1) * (x + 1) for x in range(p)]
  B[i + 1][-1] += c
for i in range(1, D + 1):
  for j in range(1, len(S[i])):
    for k in range(max(j - len(S[i - 1]) + 1, 0), min(len(B[i]), j + 1)):
      S[i][j] = max(B[i][k] + S[i - 1][j - k], S[i][j])
for i, s in enumerate(S[D]):
  if s >= G:
    print(i)
    break

Solution (Python):
from math import ceil


def main():
    d, g = [int(x) for x in input().split()]
    pcs = [[int(x) for x in input().split()] for _ in range(d)]
 
    def rec(g, i):
        nonlocal pcs
        if i <= 0:
            return float('inf')

        p, c = pcs[i-1]
        s = 100 * i
        n = min(ceil(g/s), p)
        score = s * n + c if n == p else s * n

        if score >= g:
            m = n
        else:
            m = n + rec(g-score, i-1)

        r = min(m, rec(g, i-1))
        
        return r


    print(rec(g, d))

main()

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

for i in range(D):
    p,c = pc[i]
    full_score[i] = 100 * (i+1) * p + c

ans = 10**10
from itertools import product
for case in product([0, 1], repeat=D):
    count, score = 0, 0
    for i in range(D):
        p, c = pc[i]
        count += p * case[i]
        score += full_score[i] * case[i]
    if 0 in case:
        i = D - 1 - case[::-1].index(0)
        p, c = pc[i]
        for j in range(p):
            if score >= G:
                break
            score += 100 * (i+1)
            count += 1
    if score >= G:
        ans = min(ans, count)

print(ans)

Solution (Python):
fn = lambda: map(int, input().split())
D, G = fn()
p, c = [0] * D, [0] * D
complete_scores = [0] * D
for i in range(D):
    p[i], c[i] = fn()
    complete_scores[i] = 100 * (i + 1) * p[i] + c[i]

def calc(x):
    value = 0
    count = 0
    i_unused = None
    for i, xi in enumerate(x):
        if xi == '1':
            value += complete_scores[i]
            count += p[i]
        else:
            i_unused = i
    if i_unused is not None:
        for _ in range(p[i_unused]):
            if value >= G:
                break
            else:
                value += (i_unused + 1) * 100
                count += 1
    if value < G:
        return float('inf')
    else:
        return count

fmt = '0{}b'.format(D)
x = format(0, fmt)
best_count = float('inf')
while len(x) <= D:
    best_count = min(calc(x), best_count)
    x = format(int(x, 2) + 1, fmt)

print(best_count)

Solution (Python):
import itertools
import math
D, G = map(int, raw_input().split())
p = [0]*D
c = [0]*D
for i in range(D):
  p[i], c[i] = map(int, raw_input().split())
r = sum(p)
for a in itertools.product([True, False], repeat=D):
  s = 0
  b = 0
  for i in range(D):
    if a[i]:
      s += p[i]
      pi = p[i]
      ci = c[i]
      b += (100*(i+1)*pi)+ci
  for i in range(D-1,-1,-1):
    if b>=G:
      break
    if not a[i]:
      d = min(p[i]-1, int(math.ceil(1.0*(G-b)/(100*(i+1)))))
      s += d
      b += 100*(i+1)*d
  if b>=G:
    r = min(r, s)
print r

Solution (Python):
from itertools import product

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

C = [0] * D
for i in range(D):
    p, c = pc[i]
    C[i] = 100 * (i + 1) * p + c

ans = float('inf')
for ptn in product([0, 1], repeat=D):
    point, cnt = 0, 0
    for i in range(D):
        p, c = pc[i]
        cnt += p * ptn[i]
        point += C[i] * ptn[i]

    if 0 in ptn:
        index = D - 1 - ptn[::-1].index(0)
        p, _ = pc[index]
        for i in range(p):
            if point >= G:
                break            
            point += 100 * (index + 1)
            cnt += 1

    if point >= G:
        ans = min(ans, cnt)
print(ans)

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(" "))


def solve(G, i):
    """100i点以下の問題だけでGを達成する最小問題数"""
    if i <= 0:
        return 1e9
    n = min(int(G/(100*i)), p[i-1])
    s = 100 * i * n
    if n == p[i-1]:
        s += c[i-1]
    if G > s:
        n += solve(G-s, i-1)
    return min(n, solve(G, i-1))

print(solve(G, D))

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    d,g = LI()
    p = []
    c = []
    for _ in range(d):
        t = LI()
        p.append(t[0])
        c.append(t[1])

    r = inf
    for i in range(2**d):
        tg = 0
        tr = 0
        for j in range(d):
            if 2**j & i:
                tg += c[j]
                tg += (j+1) * p[j] * 100
                tr += p[j]
        for j in range(d-1,-1,-1):
            if tg >= g:
                break
            if 2**j & i:
                continue
            ng = g - tg
            k = ng // ((j+1) * 100)
            if ng % ((j+1) * 100) > 0:
                k += 1
            if p[j] >= k:
                tr += k
                break
            tr += p[j]
            tg += p[j] * (j+1) * 100
        if r > tr:
            r = tr
    return r


print(main())

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

ans = float('inf')
for b in range(2**D):
    score = ac = 0
    for i in range(D):
        if b&(1<<i):
            p,c = src[i]
            u = (i+1)*100
            score += c + p*u
            ac += p
    if score >= G:
        ans = min(ans, ac)
        continue
    for i in range(D-1,-1,-1):
        if b&(1<<i): continue
        p,c = src[i]
        p -= 1
        u = (i+1)*100
        if score + p*u >= G:
            rem = G - score
            actmp = -(-rem//u)
            ac += actmp
            ans = min(ans, ac)
            break
        else:
            score += p*u
            ac += p
print(ans)

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


comp = [100*(i+1)*PC[i][0] + PC[i][1] for i in range(D)]



ans = sum([PC[i][0] for i in range(D)])
for bit in range(1<<D):
    
    
    point = 0
    prob = 0
    
    for j in range(D-1, -1, -1):
        if bit & (1<<j):
            point += comp[j]
            prob += PC[j][0]

    
    if point >= G:
        ans = min(ans,prob)
        continue
    
    
    else:
        for j in range(D-1, -1, -1):
            if bit & (1<<j):
                continue
            else:
                if point + 100*(j+1)*(PC[j][0]-1) < G:
                    point += 100*(j+1)*(PC[j][0]-1)
                    prob += (PC[j][0]-1)
                else:
                    temp = (G-point)//(100*(j+1)) + bool((G-point)%(100*(j+1)))
                    point += 100*(j+1)*temp
                    prob += temp
        
            if point >= G:
                ans = min(ans,prob)
                break
            

print(ans)

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

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=1e9
for x in product([0,1],repeat=D):
  cnt = 0
  pnt = 0
  i = 0
  maxi = 0 
  incompflg = False
  for y in x:
    if y == 1:
      
      cnt += p[i]
      pnt += (i+1)*100*p[i] + c[i]
    else:
      
      maxi = i
      incompflg = True
    i += 1
  
  if pnt >= G:
    ans = min(ans, cnt)
  elif incompflg and pnt + (p[maxi]-1) * (maxi+1) * 100 >= G:
    ans = min(ans, cnt+ ceil( (G-pnt) / ( (maxi+1) * 100 ) ))
  
  
print(ans)

Solution (Python):


import itertools

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


class ScoreSet:
    def __init__(self, times, score):
        self.times = times
        self.score = score


class ScoreSetSum:
    def __init__(self, times, score, bool_list):
        self.times = times
        self.score = score
        self.bool_list = bool_list


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


bool_lists = list(itertools.product([True, False], repeat=D))


scoreSetSumList = []
for bool_list in bool_lists:
    times_tmp = 0
    score_tmp = 0
    for i in range(len(bool_list)):
        if bool_list[i]:
            times_tmp += scoreSetList[i].times
            score_tmp += scoreSetList[i].score
    scoreSetSumList.append(ScoreSetSum(times_tmp, score_tmp, bool_list))


ans = float("inf")
for scoreSetSum in scoreSetSumList:
    tmp = float("inf")
    
    if scoreSetSum.score >= G:
        tmp = scoreSetSum.times
    else:
        
        for i in range(D-1, -1, -1):
            if scoreSetSum.bool_list[i] == False:
                score = scoreSetSum.score
                times = scoreSetSum.times
                
                for j in range(scoreSetList[i].times):
                    score += 100*(i+1)
                    times += 1
                    
                    if score >= G:
                        tmp = times
                        break
                    
                break
    
    ans = min(ans, tmp)

print(ans)

Solution (Python):
D,G=map(int,input().split())
p=[]
c=[]
compScore=[]
checkBits=[]
for i in range(D):
    x,y =map(int,input().split())
    p.append(x)
    c.append(y)
    compScore.append(x*(i+1)*100+y)
    checkBits.append(2**i)
    
ans = sum(p)
for bit in range(2**D):
    score = 0
    ansCand = 0
    notCompleted=set(range(D))
    for i in range(D):
        checkBit = checkBits[i]
        if (bit & checkBit) == checkBit:
            score += compScore[i]
            ansCand += p[i]
            notCompleted.remove(i)
    if score >= G:
        ans = min(ans,ansCand)
        
    else:
        if notCompleted:
            halfFilled = max(notCompleted)
            
            if score + (p[halfFilled]-1)*(halfFilled+1)*100 >= G:
                ansCand += (G-score)//((halfFilled+1)*100)
                if (G-score)%((halfFilled+1)*100)!=0:
                    ansCand += 1
                ans = min(ans,ansCand)
            



print(ans)

Solution (Python):
import math
D,G = map(int,input().split())
p=[]
c=[]
for i in range(D):
    p_tmp,c_tmp = map(int,input().split())
    p.append(p_tmp)
    c.append(c_tmp)

ans = sum(p)
for i in range(2**D):
    score_tmp = 0
    ans_tmp = 0
    for j in range(D):
        if (i>>j)%2 == 1:
            score_tmp += p[j]*(j+1)*100+c[j]
            ans_tmp += p[j]

    if ans_tmp >= ans:
        continue
    elif score_tmp >= G:
        ans = ans_tmp
        continue
    else:
        for j in range(D):
            if (i>>(D-1-j))%2 == 1:
                continue
            elif score_tmp + p[D-1-j]*(D-j)*100 < G:
                break
            else:
                ans_tmp += math.ceil((G - score_tmp)/((D-j)*100))
                ans = min(ans,ans_tmp)
                break

print(ans)

Solution (Python):
n, g = map(int, input().split())
inps = []
for i in range(1, n + 1):
    inp = list(map(int, input().split()))
    inp.append(inp[0] * i * 100 + inp[1])
    inp.append(i)
    inps.append(inp)
def at(items, goal):
    if goal <= 0:
        return 0
    result = 0
    for t, c, a, i in reversed(items):
        tn = i * 100
        cnt = min(t - 1, (goal + tn - 1) // tn)
        result += cnt
        goal -= cnt * tn
        if goal <= 0:
            return result
    return float("inf")
result = []
for i in range(2 ** n):
    items = []
    other = []
    for item in inps:
        (items if i & 1 else other).append(item)
        i >>= 1
    tcnt = sum(map(lambda x: x[0], items))
    acnt = sum(map(lambda x: x[2], items))
    ncnt = at(other, g - acnt)
    result.append(tcnt + ncnt)
print(min(result))

Solution (Python):
if_debag = False

input_texts = """5 25000
20 1000
40 1000
50 1000
30 1000
1 1000"""

input_texts = input_texts.split('\n')
it = iter(input_texts)


def my_input():
    if if_debag:
        return next(it)
    else:
        return input()

d, g = map(int, my_input().split())
ps = list()
cs = list()
for i in range(d):
    p, c = map(int, my_input().split())
    ps.append(p)
    cs.append(c)

minv = 2000
for i in range(1 << d):
    toita_mondai = 0
    sougou_tensu = 0
    for j in range(d):
        if (i >> j) & 1:
            toita_mondai += ps[j]
            sougou_tensu += (j + 1) * 100 * ps[j] + cs[j]
    if sougou_tensu >= g:
        minv = min(minv, toita_mondai)
    else:
        nokori = g - sougou_tensu
        flag = False
        for j in range(d - 1, -1, -1):
            if (i >> j) & 1:
                continue
            for _ in range(ps[j]):
                nokori -= 100 * (j + 1)
                toita_mondai += 1
                if nokori <= 0:
                    minv = min(minv, toita_mondai)
                    flag = True
                    break
            if (flag): break        
print(minv)

Solution (Python):
if_debag = False

input_texts = """5 25000
20 1000
40 1000
50 1000
30 1000
1 1000"""

input_texts = input_texts.split('\n')
it = iter(input_texts)


def my_input():
    if if_debag:
        return next(it)
    else:
        return input()

d, g = map(int, my_input().split())
ps = list()
cs = list()
for i in range(d):
    p, c = map(int, my_input().split())
    ps.append(p)
    cs.append(c)

minv = 2000
for i in range(1 << d):
    toita_mondai = 0
    sougou_tensu = 0
    for j in range(d):
        if (i >> j) & 1:
            toita_mondai += ps[j]
            sougou_tensu += (j + 1) * 100 * ps[j] + cs[j]
    if sougou_tensu >= g:
        minv = min(minv, toita_mondai)
    else:
        nokori = g - sougou_tensu
        flag = False
        for j in range(d - 1, -1, -1):
            if (i >> j) & 1:
                continue
            for _ in range(ps[j]):
                nokori -= 100 * (j + 1)
                toita_mondai += 1
                if nokori <= 0:
                    minv = min(minv, toita_mondai)
                    flag = True
                    break
            if (flag): break        
print(minv)

Solution (Python):
import numpy as np
n, g = map(int, input().split())
inps = []
for i in range(1, n + 1):
    inp = list(map(int, input().split()))
    inp.append(inp[0] * i * 100 + inp[1])
    inp.append(i)
    inps.append(inp)

def at(items, goal):
    if goal <= 0:
        return 0

    
    result = 0
    for t, c, a, i in reversed(items):
        tn = i * 100
        cnt = min(t - 1, (goal + tn - 1) // tn)
        result += cnt
        goal -= cnt * tn
        if goal <= 0:
            return result
    return float("inf")


result = []
for i in range(2 ** n):
    items = []
    other = []
    for item in inps:
        (items if i & 1 else other).append(item)
        i >>= 1

    
    tcnt = sum(map(lambda x: x[0], items))
    acnt = sum(map(lambda x: x[2], items))
    ncnt = at(other, g - acnt)
    result.append(tcnt + ncnt)
print(min(result))

Solution (Python):
d, g = map(int, input().split())
p = []
c = []
ans = 10 ** 100
for _ in range(d):
    a, b = map(int, input().split())
    p.append(a)
    c.append(b)

for bit in range(1 << d):
    point, cnt = 0, 0
    for i in range(d):
        if bit >> i & 1:
            point += (i+1) * 100 * p[i] + c[i]
            cnt += p[i]

    if g <= point:
        ans = min(ans, cnt)
    else:
        for i in reversed(range(d)):
            if not(bit >> i & 1):
                for j in range(p[i]):
                    if point >= g:
                        break
                    point += 100 * (i+1)
                    cnt += 1
        ans = min(ans, cnt)
print(ans)

Solution (Python):
d,g = map(int,input().split())
a = list(list(map(int, input().split())) for x in range(d))

minmin = 100000

for i in range(0,2**d):
    f = [True]
    min = 0
    sum = 0
    binary = format(i, 'b')
    binary = binary[::-1]
    
    list2=[i for i, x in enumerate(binary) if x == '1']
    
    for i in range(len(list2)):
        sum+=a[list2[i]][0]*100*(list2[i]+1)+a[list2[i]][1]
        min += a[list2[i]][0]
    if (sum<g) and (len(list2)<d):
        
        d2 = d-1
        while (1):
            
            if len(list2)==0:
                break
            if d2 in list2:
                d2 = d2-1
                continue
            else:
                break
        l = 0 
        while(sum<g):
            if l >= a[d2][0]:
                f[0]=False
                break
            
            min +=1
            sum += 100*(d2+1)
            l += 1
        if sum<g:
            f[0]=False
    if (f[0]==True)and(min < minmin):
        minmin = min
        
    


print(minmin)

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

A=[map(int,raw_input().split()) for i in range(D)]

N=1000
dp=[ [ float("-inf") for i in range(N+100)]  for j in range(D) ] 

p=A[0][0]
c=A[0][1]


for i in range(1,p+1):
	if i==p: dp[0][i]=i*100+c
	else: dp[0][i]=i*100

for i in range(D):
	dp[i][0]=0



for k in range(1,D):
	p=A[k][0]    
	c=A[k][1]    

	for i in range(N):		         
		for j in range(1,p+1):    
			dp[k][i+j]=max( dp[k][i+j], dp[k-1][i]+j*(k+1)*100, dp[k-1][i+j] )
		dp[k][i+j]=max( dp[k][i+j], dp[k-1][i]+j*(k+1)*100+c,dp[k-1][i+j] )



for idx,i in enumerate(dp[D-1]):
	if i>=G:
		print idx
		quit()

Solution (Python):
import math

d, g = [int(_) for _ in input().split(' ')]
p = []
c = []
for _ in range(d):
    temp = [int(_) for _ in input().split(' ')]
    p.append(temp[0])
    c.append(temp[1])

answer = 1001
for i in range(2 ** d):
    sc = 0
    pr = 0
    for j in range(d, 0, -1):
        if i & (1 << (j - 1)) > 0:
            sc += j * 100 * p[j - 1] + c[j - 1]
            pr += p[j - 1]
    for j in range(d, 0, -1):
        if sc < g and i & (1 << (j - 1)) == 0:
            temp = min(math.ceil((g - sc) / (j * 100)), p[j - 1] - 1)
            sc += temp * (j * 100)
            pr += temp
    if sc >= g and pr < answer:
        answer = pr

print(answer)

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

S=list(itertools.product(range(2),repeat=D))
ans=sum(p)
for seq in S:
    score=0
    prove=0
    for i in range(D):
        if seq[i]==1:
            score+=(p[i]*100*(i+1)+c[i])
            prove+=p[i]
    if score>=G:
        if ans>prove:
            ans=prove
        continue
    j=-1
    for i in range(D):
        if seq[i]==0:
            j=i
    for k in range(p[j]):
        prove+=1
        score+=100*(j+1)
        if G<=score:
            break
    if G>score:
        continue
    if ans>prove:
        ans=prove
print(ans)

Solution (Python):
d, g = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(d)]
r = float('inf')
for b in range(1<<d):
    x = n = 0
    j = -1
    for i in range(d):
        if b & 1<<i:
            p, c = a[i]
            x += p*(i+1)*100+c
            n += p
        else:
            j = i
    if j != -1:
        p, c = a[j]
        y = 100*(j+1)
        m = max(0,g-x+y-1)//y
        if m < p:
            x += m*y+c
            n += m
    if x >= g:
        r = min(r, n)
print(r)

Solution (Python):
import math
D,G = map(int,input().split())
p=[]
c=[]
for i in range(D):
    p_tmp,c_tmp = map(int,input().split())
    p.append(p_tmp)
    c.append(c_tmp)

ans = sum(p)
for i in range(2**D):
    score_tmp = 0
    ans_tmp = 0
    for j in range(D):
        if (i>>j)%2 == 1:
            score_tmp += p[j]*(j+1)*100+c[j]
            ans_tmp += p[j]

    if ans_tmp >= ans:
        continue
    elif score_tmp >= G:
        ans = min(ans,ans_tmp)
        continue
    else:
        for j in range(D):
            if (i>>(D-1-j))%2 == 1:
                continue
            elif score_tmp + p[D-1-j]*(D-j)*100 < G:
                break
            else:
                ans_tmp += math.ceil((G - score_tmp)/((D-j)*100))
                ans = min(ans,ans_tmp)
                break

print(ans)

Solution (Python):
D,G = map(int,input().split())
G = G/100
P = []; C = []
for i in range(D):
  p,c = map(int,input().split())
  P.append(p)
  C.append(c/100)
m = 10**3
for k in range(2**D):
  R = list(range(D))[::-1]
  point = G
  prob = 0
  for d in range(D):
    if k & 1<<d:
      p = P[d]; c = C[d]
      point -= (d+1)*p + c
      prob += p
      R.remove(d)
  for r in R:
    if point > 0:
      p = P[r]
      if point/(r+1) <= p:
        prob += -(-point//(r+1))
        point = 0
      else:
        point -= (r+1)*p + C[r]
        prob += p
  if m >= prob:
    m = prob
print(int(m))

Solution (Python):
import math
D,G = map(int,input().split())
p=[]
c=[]
for i in range(D):
    p_tmp,c_tmp = map(int,input().split())
    p.append(p_tmp)
    c.append(c_tmp)

ans = sum(p)
for i in range(2**D):
    score_tmp = 0
    ans_tmp = 0
    for j in range(D):
        if (i>>j)%2 == 1:
            score_tmp += p[j]*(j+1)*100+c[j]
            ans_tmp += p[j]

    if ans_tmp >= ans:
        continue
    elif score_tmp >= G:
        ans = ans_tmp
        continue
    else:
        for j in range(D):
            if (i>>(D-1-j))%2 == 1:
                continue
            elif score_tmp + p[D-1-j]*(D-j)*100 < G:
                break
            else:
                ans_tmp += math.ceil((G - score_tmp)/((D-j)*100))
                ans = min(ans,ans_tmp)
                break

print(ans)

Solution (Python):
from itertools import product
d,g = (int(i) for i in input().split())
p = [[int(i) for i in input().split()] for i in range(d)]
q,ans = [],1001
for i in range(d): q.append(p[i][0]*(i+1)*100+p[i][1]) 
for i in product(range(2), repeat=d):
	m,n,x = 0,0,[]
	for j in range(d):
		if i[j]==1: m,n = m+q[j],n+p[j][0]
		else: x.append(j)
	if m>=g: ans = min(ans,n)
	else:
		for k in x:
			num = (g-m+99)//((k+1)*100)
			if num<p[k][0]: ans = min(ans,n+num)
print(max(1,ans))

Solution (Python):
D, G = [int(_) for _ in input().split()]
PC = [tuple(int(_) for _ in input().split()) for i in range(D)]
P = [_[0] for _ in PC]
C = [_[1] for _ in PC]

from itertools import product
from math import ceil

INF = 10**20

def calc(pat):
    solved_promlems = 0
    total_score = 0
    left = None
    for e, score, problem_nums, complete_score in zip(pat, range(100, (D+1)*100, 100), P, C):
        if e:
            total_score += score * problem_nums + complete_score
            solved_promlems += problem_nums
        else:
            left = score, problem_nums
    if total_score >= G:
        return solved_promlems
    if left:
        score, problem_nums = left
        n = ceil((G - total_score) / score)
        if 1 <= n < problem_nums:
            return solved_promlems + n
    return INF

result = min(calc(pat) for pat in product((0, 1), repeat=D))

print(result)

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

from itertools import product

INF = 10**20

def calc(es):
    r = 0
    last_row = None
    result = 0
    for i, e, pc in zip(range(D), es, PC):
        d = (i+1) * 100
        if e:
            r += d * pc[0] + pc[1]
            result += pc[0]
        else:
            last_row = d, pc[0]
    if r >= G:
        return result
    if last_row:
        n = (G - r + last_row[0] - 1) // last_row[0]
        if 1 <= n < last_row[1]:
            return result + n
    return INF

result = min(calc(pat) for pat in product((0, 1), repeat=D))

print(result)