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):
def main():
    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 = float('inf')
    for i in range(1 << D):
        cnt = 0
        score = 0
        tmp = 0
        for j in range(D):
            if (i >> j) & 1:
                score += c[j] + 100 * (j + 1) * p[j]
                cnt += p[j]
            else:
                tmp = j
                
        if score < G:
            for k in range(1,p[tmp]):
                score += 100 * (tmp + 1)
                cnt += 1
                if score >= G:
                    break
        
        if score >= G:
            ans = min(ans,cnt)
    
    print(ans)


main()

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

score = 0
p = []
c = []
for i in range(d):
    p_tmp, c_tmp = [int(i) for i in input().split()]
    p.append(p_tmp)
    c.append(c_tmp)

num = []
for i in range(2**d):
    num_tmp = 0
    score = 0
    not_comp = []
    for j in range(d):
        if i >> j & 1:
            score += p[j] * 100 * (j+1) + c[j]
            num_tmp += p[j]
        else:
            not_comp.append(j)

    for j in not_comp[::-1]:
        if score < g:
            num_j = min(p[j]-1, (g-score-1)//(100*(j+1))+1)
            score += num_j * 100*(j+1)
            num_tmp += num_j
    if score >= g:
        num.append(num_tmp)

ans = min(num)
print(ans)

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

score = 0
p = []
c = []
for i in range(d):
    p_tmp, c_tmp = [int(i) for i in input().split()]
    p.append(p_tmp)
    c.append(c_tmp)

num = []
for i in range(2**d):
    num_tmp = 0
    score = 0
    not_comp = []
    for j in range(d):
        if i >> j & 1:
            score += p[j] * 100 * (j+1) + c[j]
            num_tmp += p[j]
        else:
            not_comp.append(j)

    for j in not_comp[::-1]:
        for k in range(p[j]-1):
            if score < g:
                score += 100 * (j+1)
                num_tmp += 1
            else:
                break
        else:
            continue
        break
    if score >= g:
        num.append(num_tmp)

ans = min(num)
print(ans)

Solution (Python):
D, G = map(int, input().split())
PC = [0] + [tuple(map(int, input().split())) for _ in range(D)]
SHORT_OF_SCORE = 10**9


def solve(p, g):
    if p == 0:
        return SHORT_OF_SCORE

    
    case_solve_p = min(g//(p*100), PC[p][0])
    reward = 100 * p * case_solve_p + \
        (PC[p][1] if case_solve_p == PC[p][0] else 0)

    if reward < g:
        case_solve_p += solve(p-1, g-reward)

    
    case_not_solve_p = solve(p-1, g)
    return min(case_solve_p, solve(p-1, g))


print(solve(D, G))

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

cnts = []
bonuses = []
for i in range(D):
    a, b = [int(_) for _ in input().split()]
    cnts.append(a)
    bonuses.append(b)


ans = 1e12
for i in range(2 ** D + 1):
    j = i
    bidx = []
    cnt = 0
    point = 0
    for j in range(D):
        if (i >> j) & 1:
            bidx.append(j)
            point += bonuses[j] + cnts[j] * 100 * (j + 1)
            cnt += cnts[j]

    for j in range(D - 1, -1, -1):
        if point >= G: break
        if j in bidx: continue
        for k in range(1, cnts[j] + 1):
            if point >= G: break
            point += (j + 1) * 100
            cnt += 1
    ans = min(cnt, ans)
print(ans)

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

solve_lis = []
for i in range(2**d):
    solve = 0
    point = 0
    way = True
    for j in range(d-1, -1, -1):
        if ((i >> j) & 1):
            solve += p[j]
            point += p[j] * 100 * (j + 1) + c[j]
        elif way == True:
            index = j
            way = False
    for k in range(p[index]):
        if k > 0:
            solve += 1
            point += 100 * (index + 1)
        if point >= g:
             solve_lis.append(solve)
    
print(min(solve_lis))

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

def all_green(t,s):
    if t == -1:
        return float('inf')
    num = min(PC[t][0],s//(100*(t+1)))
    k = num * 100 * (t+1)
    if num == PC[t][0]:
        k += PC[t][1]
    if k < s:
        num += all_green(t-1,s-k)
    return min(num,all_green(t-1,s))
print(all_green(D-1,G))

Solution (Python):
d, g = map(int, input().split())
dic = {}
ans = 9999999
for i in range(1, d+1):
    dic[i] = list(map(int, input().split()))

for i in range(2**d):
    total = 0
    count = 0
    select_list = list(range(1, d+1))
    for j in range(d):
        if (i >> j) & 1:
            num = dic[j+1][0]
            total += 100*(j+1)*num + dic[j+1][1]
            count += dic[j+1][0]
            select_list.remove(j+1)

    if total >= g:
        if count < ans:
            ans = count
            continue
        else:
            continue

    else:
        select = max(select_list)
        select_num = dic[select][0]
        for _ in range(select_num):
            total += 100*select
            count += 1

            if total >= g:
                if count < ans:
                    ans = count
                    break
                else:
                    break

print(ans)

Solution (Python):
from operator import itemgetter

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

def com(d, s, ans):
    if d == D:
        ans.append(s)
        return ans
    a = s[:]
    a.append(1)
    ans = com(d+1, a, ans)
    b = s[:]
    b.append(0)
    ans = com(d+1, b, ans)
    return ans

L = com(0, [], [])
ans = 10000
for l in L:
    point = 0
    probs = 0
    uncom = []
    for i, com in enumerate(l):
        if com == 0:
            uncom.append(i)
        else:
            p, c = PC[i]
            point += (i+1)*100*p + c
            probs += p
    
    if point >= G:
        ans = min(ans, probs)
        continue
    uncom.sort(reverse=True)
    re = G - point
    for un in uncom:
        p, c = PC[un]
        
        if (un+1)*100*(p-1) >= re:
            rem = 1 if re % ((un+1)*100) > 0 else 0
            probs += re // ((un+1)*100) + rem
            re = 0
            break
        re -= (un+1)*100*(p-1)
        probs += p-1
    
    if re > 0:
        continue
    ans = min(ans, probs)
print(ans)

Solution (Python):
D,G = map(int,input().split())
cnts = []
points = []
for i in range(1,D + 1):
        p,c = map(int,input().split())
        points.append([p, i * 100, i * 100 * p + c, c])

for i in range(1 << D):
        point = 0
        cnt = 0
        not_used = [_ for _ in range(D)]
        for j in range(D):
                if 1 << j & i:
                        many,one,all,bounsu = points[j]
                        cnt += many
                        point += all
                        not_used.remove(j)
        if point < G:
                biggest = points[not_used[len(not_used) - 1]]
                if biggest[2] < G - point:
                        continue
                cnt += (G - point) // biggest[1]
                if (G - point) % biggest[1] != 0:
                        cnt += 1
        cnts.append(cnt)
print(min(cnts))

Solution (Python):
D,G=map(int,input().split())
c=[0]+[list(map(int,input().split())) for i in range(D)]
def f(t,s):
	if t==0:
		return 10**9
	
	
	l=min(s//(t*100),c[t][0])
	k=100*t*l
 
	
	if l==c[t][0]:
		k+=c[t][1]
	
	if k<s:
		l+=f(t-1,s-k)
	
	return min(l,f(t-1,s))
 
print(f(D,G))

Solution (Python):
d,g = map(int,input().split())
import math
pc = []
for i in range(d):
    pc.append(list(map(int,input().split())))
ans = 10000
for i in range(2**d):
    score = 0
    num = 0
    for j in range(d):
        if i>>j & 1 == 1:
            score += pc[j][0]*(j+1)*100+pc[j][1]
            num += pc[j][0]
    for j in range(d-1,-1,-1):
        if i>>j & 1 == 0:
            if g>score:
                so = math.ceil((g-score)/((j+1)*100))
                if so < pc[j][0]:
                    ans = min(ans,num+so)
            else:
                ans = min(ans,num)
        if g<=score:
            ans = min(ans,num)
print(ans)

Solution (Python):
a,b=map(int,input().split())
c=[0]+[list(map(int,input().split())) for i in range(a)]
print()
def f(t,s):
	if t==0:
		return 10**9
	
	
	l=min(s//(t*100),c[t][0])
	k=100*t*l

	
	if l==c[t][0]:
		k+=c[t][1]
	
	if k<s:
		l+=f(t-1,s-k)
	
	return min(l,f(t-1,s))

print(f(a,b))

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

ans = 1000
for i in range(1 << D):
    S = G
    P = 0
    max_j = 0
    for j in range(D):
        if i >> j & 1 == 1:
            P += problems[j][0]
            S -= 100 * (j + 1) * problems[j][0] + problems[j][1]
        else:
            max_j = j
    if S > 0:
        p = 100 * (max_j + 1)
        need = (S + p - 1) // p
        if need >= problems[max_j][0]:
            continue
        P += need
    ans = min(P, ans)
print(ans)

Solution (Python):
d,g=map(int,input().split())
l = [list(map(int,input().split())) for i in range(d)]
def f(t,s):
    if t==-1:
        return float('inf')
    num = min(l[t][0],s//((t+1)*100))
    k = num*(t+1)*100
    if num==l[t][0]:
        k += l[t][1]
    if k<s:
        num += f(t-1,s-k)
    return min(num,f(t-1,s))
 
print(f(d-1,g))

Solution (Python):
from math import ceil

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

pc_list = [[i]+list(map(int,input().split())) for i in range(D)]
def rindex_zero(l):
    return len(l) - l[::-1].index(0)-1

def func(g,cnt,l):
    if len(l) == D:
        if g <= 0:
            return cnt
        idx = rindex_zero(l)
        i,p,c = pc_list[idx]
        if g <= 100*(i+1)*(p-1):
            cnt += ceil(g/(100*(i+1)))
            return cnt
        return 10**9
    length = len(l)
    i,p,c = pc_list[length]

    a = func(g-(100*(i+1)*p+c), cnt+p,l+[1])
    b = func(g, cnt,l +[0])
    return min(a,b)
        
print(func(G,0,[]))

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

lst = [list(map(int, input().split())) for i in range(D)]
ans = []
ref = []
for i,v in enumerate(lst):
	ref.append(v[0]*(i+1)*100 + v[1])
  
for i in range(2 ** D):
	score = 0
	cnt = 0
	for j in range(D):  
		if ((i >> j) & 1):  
			score += ref[j]
			cnt += lst[j][0]
	if (score >= G):
		ans.append(cnt)
	else:
		for l in range(D)[::-1]:
			if ((i >> l) & 1):
				continue
			for _ in range(1,lst[l][0]):
				score += (l+1) * 100
				cnt += 1
                
				if score >= G:
					ans.append(cnt)  
					break
print(min(ans))

Solution (Python):
d,g=map(int,input().split())
ans=10000
p=[]
c=[]
for i in range(d):
    a,b=map(int,input().split())
    p.append(a)
    c.append(b)
for i in range(2**d):
    x=0
    cou=0
    l=[]
    for j in range(d):
        if ((i>>j)&1):
            x+=c[j]+p[j]*(j+1)*100
            cou+=p[j]
        else:
            l.append(j)
    l.sort(reverse=True)
    k=0
    while x<g:
        for _ in range(p[l[k]]):
            if x>=g:
                break
            cou+=1
            x+=(100*(l[k]+1))
        k+=1
        if k>=len(l):
            break
    ans=min(ans,cou)
print(ans)

Solution (Python):
d,g=map(int,input().split())
ans=10000
p=[]
c=[]
for i in range(d):
    a,b=map(int,input().split())
    p.append(a)
    c.append(b)
for i in range(2**d):
    x=0
    cou=0
    l=[]
    for j in range(d):
        if ((i>>j)&1):
            x+=c[j]+p[j]*(j+1)*100
            cou+=p[j]
        else:
            l.append(j)
    l.sort(reverse=True)
    k=0
    while x<g:
        for _ in range(p[l[k]]):
            if x>=g:
                break
            cou+=1
            x+=(100*(l[k]+1))
        k+=1
        if k>=len(l):
            break
    ans=min(ans,cou)
print(ans)

Solution (Python):
import math

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

l_money = [[(i+1)*100]*(l[i][0]-1) + [(i+1)*100 + l[i][1]] for i in range(d)]
l_sum = [sum(l_money[x]) for x in range(d)]




ans = float("inf")
for i in range(2**d):
    cnt = 0
    now = 0
    amari = []
    for j in range(d):
        if ((i>>j) & 1):
            now += l_sum[j]
            cnt += l[j][0]
        else:
            amari.append(l_money[j][:-1])
    amari.sort(reverse=True)

    

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

    cnt_add_min = 1000
    for k in range(len(amari)):
        if amari[k]:
            cnt_add = math.ceil((g-now)/amari[k][0])
            if cnt_add <= len(amari[k]):
                cnt_add_min = min(cnt_add_min, cnt_add)

    if cnt_add_min != 1000:
        cnt += cnt_add_min
        ans = min(ans, cnt)
    else:
        continue

print(ans)

Solution (Python):
d,g = map(int,input().split())
table = []
for i in range(d):
  table.append( [(i+1) * 100] + list(map(int,input().split())) )
time = [0 for _ in range(d)]

def suc(time):
  cnt = 0
  while cnt < d:
    if time[d-1-cnt] == 0:
      time[d-1-cnt] = 1
      return time
      break
    else:
      time[d-1-cnt] = 0
      cnt += 1
  else:
    return 'over'
def here(time):
  cnt = 0
  while time[d-1-cnt] == 1:
    cnt += 1
    if cnt == d+1:
      return 'full'
      break
  else:
    return cnt
ans = []
while time != 'over':
  now = 0
  scr = 0
  hh = here(time)
  if hh == 'full':
    h = 'fuck'
  else:
    h = table[d-1-here(time)]
  for i in range(d):
    now += time[i] * table[i][1]
    scr += time[i] * (table[i][0] * table[i][1] + table[i][2])
  if scr >= g:
    ans.append(now)
  else:
    rest = g - scr
    if rest < h[0] * h[1]:
      now += (rest-1) // h[0] + 1
      ans.append(now)
  time = suc(time)
print(min(ans))

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

for j in range(2**d):
    total = 0
    count = 0
    for i in range(d):
        if (j >> i) & 1:
            total += 100*(i+1)*q_list[i][0] + q_list[i][1]
            count += q_list[i][0]

    if total >= g:
        count_list.append(count)
        continue

    else:
        for t in range(d):
            digit = str(d)
            if str(format(j, '0'+digit+'b'))[t] == '0':
                for x in range(q_list[d-t-1][0]-1):
                    count += 1
                    total += 100 * (d-t)

                    if total >= g:
                        count_list.append(count)
                        break
                break

print(min(count_list))

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

num = 2**d

score = 0
ans = 0

use = [0,1]

def nokori(use,score):
    tmp = 0
    for i in range(d):
        
        if d-1-i not in use:
            if pc[d-1-i][0] * (d-1-i+1) * 100 >= score:
                tmp += (score +(d-1-i+1) * 100 - 1) // ( (d-1-i+1) * 100 )
                return tmp
            elif pc[d-1-i][0] * (d-1-i+1) * 100 + pc[d-1-i][1] >= score:
                tmp += pc[d-1-i][0]
                return tmp
            else:
                tmp += pc[d-1-i][0]
                score -= pc[d-1-i][0] * (d-1-i+1) * 100 + pc[d-1-i][1]
kouho = []

kouho.append(nokori([-1],g))


for i in range(num):
    use = []
    ans = 0
    score = 0
    cur = i
    
    for j in range(d):
        if cur == 0:
            continue
        elif cur% 2 == 1:
            
            score += pc[j][0] * (j+1) * 100 + pc[j][1]
            ans += pc[j][0]
            use.append(j)
            
        
            
            
        cur = cur // 2
    
    if score >= g:
        kouho.append(ans)
    else:
        
        
        kouho.append(ans+nokori(use,g-score))
        


kouho.sort()
print(kouho[0])

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

ans = float('inf')
for i in range(2 ** n):
    g_sum = 0
    count = 0
    rest_max = -1
    for j in range(n):
        if (i >> j) & 1:
            g_sum += 100 * (j + 1) * a[j][0] + a[j][1]
            count += a[j][0]
        else:
            rest_max = j

    if g_sum < g:
        s1 = 100 * (rest_max + 1)
        need = (g - g_sum + s1 - 1) // s1
        if need >= a[rest_max][0]:
            continue
        count += need
    ans = min(ans, count)

print(ans)

Solution (Python):



def solve(D, G, ps, cs):
  ans = 100000000
  for mask in range(1 << D):
    s = 0
    num = 0
    rest_max = -1
    for i in range(D):
      if mask >> i & 1:
        s += 100 * (i+1) * ps[i] + cs[i]
        num += ps[i]
      else:
        rest_max = i
    if s < G:
      s1 = 100 * (rest_max + 1)
      need = int((G - s + s1 - 1) / s1)
      if need >= ps[rest_max]:
        continue
      num += need
    ans = min(ans, num)
  return ans
  

if __name__ == '__main__':
  D, G = map(int, input().split(' '))
  ps = []
  cs = []
  for i in range(D):
    p, c = map(int, input().split(' '))
    ps.append(p)
    cs.append(c)
  print(solve(D, G, ps, cs))

Solution (Python):
import itertools


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

P     = [None] * D
C     = [None] * D
count = [None] * D
score = [None] * D

for i in range(D):
    p, c          = map(int, input().split())
    P[i]          = p
    C[i]          = c
    count[i]      = list(range(p+1))
    score[i]      = [100 * (i+1) * j for j in range(p+1)]
    score[i][-1] += c

answer = sum(P)

for is_complete in itertools.product([True, False], repeat=D):
    score_tmp  = 0
    count_tmp  = 0
    score_tmp += sum([score[i][-1] for i in range(D) if is_complete[i]])
    count_tmp += sum([count[i][-1] for i in range(D) if is_complete[i]])
    if score_tmp < G:
        for i in list(range(D))[::-1]:
            if is_complete[i] == False:
                if (G - score_tmp) % (100 * (i+1)) == 0:
                    count_add  = min((G - score_tmp) // (100 * (i+1)),     P[i] - 1)
                else:
                    count_add  = min((G - score_tmp) // (100 * (i+1)) + 1, P[i] - 1)
                score_add      = 100 * (i+1) * count_add
                count_tmp     += count_add
                score_tmp     += score_add
            if score_tmp >= G:
                break
    if score_tmp >= G:
        answer = min(answer, count_tmp)

print(answer)

Solution (Python):

import sys, math, fractions, itertools


def solve(D: int, G: int, p: "List[int]", c: "List[int]"):
    mn = 1e5
    for i in range(1 << D):
        score = 0
        count = 0
        for j in range(D):
            if i >> j & 1 == 1:
                score += p[j] * 100 * (j+1) + c[j]
                count += p[j]
        if score >= G:
            mn = min(mn, count)
            continue
        for k in range(D):
            j = D - k - 1
            if i >> j & 1 == 0:
                if score + 100*(j+1)*(p[j]-1) >= G:
                    count += math.ceil((G - score) / (100*(j+1)))
                    score += 100*(j+1)*count
                    break
                else:
                    score += 100*(j+1)*(p[j]-1)
                    count += p[j] - 1
        
        if score >= G:
            mn = min(mn, count)
    print(mn)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  
    G = int(next(tokens))  
    p = [int()] * (D)  
    c = [int()] * (D)  
    for i in range(D):
        p[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(D, G, p, c)

if __name__ == '__main__':
    main()

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

p = [] 
c = [] 
ans = [] 
ss = 0
cnt = 0

for _ in range(d): 
    pp,cc = map(int,input().split())
    p.append(pp)
    c.append(cc)

for x in range(2**d): 
    ss = 0 
    cnt = 0 
    for i in range(d): 
        if (x >> i) & 1:
            ss += (i+1)*100*p[i] + c[i]
            cnt += p[i]
    
    if ss >= g: 
        ans.append(cnt)
    
    else:
        for l in range(d)[::-1]:
            if ((x>>l)&1):
                continue
            for _ in range(1,p[l]):
                ss += (l+1) * 100
                cnt += 1
                
                if ss >= g:
                    ans.append(cnt)
                    break

print(min(ans))

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

p = []
c = []
ans = []
cnt = 0
ss = 0
for _ in range(d):
    pp, cc = map(int, input().split())

    p.append(pp)
    c.append(cc)



for x in range(2**d):
    ss = 0
    cnt = 0
    for i in range(d):
        if (x>>i)&1:

            ss += (i+1)*100*p[i] + c[i]
            cnt += p[i]
    if ss>=g:
        ans.append(cnt)

    else:
        for l in range(d)[::-1]:
            if  ((x >> l) & 1):
                continue

            for _ in range(1,p[l]):
                ss += (l+1)*100
                cnt += 1

                if ss>=g:
                    ans.append(cnt)
                    break

print(min(ans))

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

for i in range(2**D):
	point = 0
	count = 0
	for j in range(D):
		if (i>>j)&1:
			point += 100*(j+1)*X[j][0]+X[j][1]
			count += X[j][0]
	if 	G > point:
		for k in range(D)[::-1]:
			if (i>>k)&1==0:
				if (G-point) <= 100*(k+1)*(X[k][0]-1):
					count += -((-(G-point)) // (100*(k+1)))
					break
				else:
					count = 10**5
					break
	if ans == 0 or count < ans:
		ans = count

print(ans)

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

p = [tuple(map(int, input().split())) for _ in range(d)]
ans = 1000

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

Solution (Python):
import math

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

min = 10 ** 9
for i in range(2**(D)):
  count = 0
  p_count = 0
  no_solve = []
  for j in range(D):
    if i>>j&1 == 1:
      count += s_max[j]
      p_count += pn[j]
    else:
      no_solve.append(j)
  if count >= G:
    if min > p_count:
      min = p_count
  else:
    box = math.ceil((G - count) / (100 * (no_solve[-1]+1)))
    if box < pn[no_solve[-1]]:
      p_count += box
      if min > p_count:
        min = p_count
print(min)

Solution (Python):
import math
D,G = map(int,input().split())
s_max = []
pn = []
for i in range(1,D+1):
    p,c = map(int,input().split())
    s_max.append(100*i*p+c)
    pn.append(p)
num_all = sum(pn)
for i in range(2<<D):
    a = []
    for j in range(D):
        a.append(i%2)
        i = i//2
    s = sum([s_max[i] for i in range(D) if a[i] == 1])
    if 0 in a:
        m = max([i for i in range(D) if a[i] == 0])
        num = math.ceil((G-s)/(100*(m+1)))
        if G> s and num <= pn[m]:
            num_all = min(num_all,sum([pn[i] for i in range(D) if a[i] == 1])+num)
        elif G <= s:
            num_all = min(num_all,sum([pn[i] for i in range(D) if a[i] == 1]))
print(num_all)

Solution (Python):

import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline

import math

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

total = []
for i in range(D):
	total.append((i+1)*pc[i][0]*100 + pc[i][1])

minn = 100000000
for i in range(2**D):
	sum = 0
	n = 0
	max0 = -1
	for j in range(D):
		x = (i & (2 ** j)) // (2 ** j)
		sum += total[j]*x
		n += pc[j][0]*x
		if x == 0:
			max0 = j

	if sum >= G:
		minn = min(minn, n)
	elif sum < G:
		rest = math.ceil((G - sum) / (100*(max0 + 1)))
		if rest < pc[max0][0]:
			minn = min(minn, n + rest)
print(minn)

Solution (Python):
D, G = map(int, input().split())
P = list()
for i in range(1, D + 1):
    p, c = map(int, input().split())
    P.append((100 * i, p, c))

ans = float('inf')
for i in range(2 ** D):
    points = 0
    problems = 0
    for d in range(D):
        if (i >> d) & 1:
            i100, p, c = P[d]
            points += i100 * p + c
            problems += p
    if points >= G:
        ans = min(ans, problems)
        continue
    for d in reversed(range(D)):
        if (i >> d) & 1:
            continue
        i100, p, c = P[d]
        for j in range(p):
            if points >= G:
                break
            points += i100
            problems += 1
    ans = min(ans, problems)

print(ans)

Solution (Python):


import sys

sys.setrecursionlimit(10**7)


input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def solve(d, g, pc):
    min_num = 100 * d + 1
    for i in range(2**d):
        num = 0
        score = 0
        offset = -1
        for j in range(d):
            if (i >> j) & 1:
                
                
                p, c = pc[j]
                
                num += p
                score += 100 * (j + 1) * p + c
                
            else:
                offset = j
                

        if score < g:
            
            short = 100 * (offset + 1)
            
            need = (g - score + short - 1) // short
            if need >= pc[offset][0]:
                continue
            
            num += need
            

        min_num = min(min_num, num)
        

    return min_num


def main():
    d, g = read_h()
    pc = read_v(d, m=2)
    

    num = solve(d, g, pc)
    print(num)


if __name__ == '__main__':
    main()

Solution (Python):
import math
D, G = map(int, input().split())
L = [[int(i) for i in input().split()] for j in range(D)]
p = [L[i][0] for i in range(D)]
q = [L[i][1] for i in range(D)]





M = [L[i][0]*(i+1)*100+L[i][1] for i in range(D)]
lis = []
for i in range(1 << D):
    s = [0, 0]
    for j in range(D):
        if ((i >> j) & 1) == 1:
            s[0] += p[j]
            s[1] += M[j]
    for j in range(D):
        if ((i >> j) & 1) == 0:
            lis.append(s+[j+1])
        else:
            lis.append(s+[0])

ans = 1010
for l in lis:
    if G <= l[1]:
        ans = min(ans, l[0])
    elif G - l[1] <= l[2] * 100 * (p[l[2]-1]-1):
        ct = math.ceil((G-l[1]) / (l[2]*100))
        ans = min(ans, l[0]+ct)

print(ans)

Solution (Python):
import math
D, G = map(int, input().split())
L = [[int(i) for i in input().split()] for j in range(D)]
p = [L[i][0] for i in range(D)]
q = [L[i][1] for i in range(D)]





M = [L[i][0]*(i+1)*100+L[i][1] for i in range(D)]
lis = []
for i in range(1 << D):
    s = [0, 0]
    for j in range(D):
        if ((i >> j) & 1) == 1:
            s[0] += p[j]
            s[1] += M[j]
    for j in range(D):
        if ((i >> j) & 1) == 0:
            lis.append(s+[j+1])
        else:
            lis.append(s+[0])

ans = 1010
for l in lis:
    if G <= l[1]:
        ans = min(ans, l[0])
    elif G - l[1] <= l[2] * 100 * (p[l[2]-1]-1):
        ct = ((G-l[1])+(l[2]*100)-1) // (l[2]*100)
        ans = min(ans, l[0]+ct)

print(ans)

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

ans_min = 10 ** 10
for i in range(2 ** D):
    flag = bin(i)[2:].zfill(D)
    p_max = [0] * D
    score = 0
    ans = 0
    for j in range(D):
        if flag[j] == '1':
            p_max[j] = 0
            ans += prob[j][0]
            score += prob[j][1] + 100 * (j + 1) * prob[j][0]
        else:
            p_max[j] = prob[j][0] - 1
    p_use = D
    while score < G:
        p_use -= 1
        if p_use == -1:
            ans = 10 ** 10
            break
        solve = min((G - score - 1) // (100 * (p_use + 1)) + 1, p_max[p_use])
        ans += solve
        score += solve * 100 * (p_use + 1)
    ans_min = min(ans, ans_min)

print(ans_min)