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

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

p.reverse()

ans = float('inf')

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

print(ans)

Solution (Python):
from itertools import product
from math import ceil
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = 10**9
for bit in product([0, 1], repeat=d):
    score = 0
    probs = 0
    for i, b in enumerate(bit):
        p, c = pc[i]
        if b==1:
            probs+=p
            score+=100*(i+1)*p
            score+=c
    if score >= g:
        ans = min(ans, probs)
    else:
        
        for i, b in list(enumerate(bit))[::-1]:
            p, c = pc[i]
            if b==1:
                continue
            if score+100*(i+1)*p >= g:
                a = ceil((g-score)/(100*(i+1)))
                probs += a
                score += (100*(i+1))*a
                if a == p: score += c
                break
            else:
                probs += p
                score += (100*(i+1))*p+c
                if score >= g: break
        if score >= g:
            ans = min(ans, probs)
print(ans)

Solution (Python):
import bisect


def main():
  D, G = list(map(int, input().split()))
  P = []
  for i in range(1, D+1):
    P.append(tuple(map(int, input().split())))

  
  minp = float('inf')
  for bit in range(1 << D):
    total = 0
    num_p = 0
    bset = set()
    for i in range(D):
      mask = 1 << i
      if bit & mask:
        total += P[i][1] + 100*(i+1)*P[i][0]
        num_p += P[i][0]
        bset.add(i)

    

    res = G - total
    if res <= 0:
      if num_p < minp:
        minp = num_p
      continue

    for i in reversed(sorted(set([i for i in range(D)]) - bset)):
      maxv = 100*(i+1) * (P[i][0]-1)

      if res <= maxv:
        num_take = max(min(bisect.bisect(list(range(0, maxv+100*(i+1), 100*(i+1))), res)-1, P[i][0]-1), 1)
        
        
        num_p += num_take
        res -= 100*(i+1)*num_take
        if num_p < minp:
          minp = num_p
        break

      res -= maxv
      
      num_p += (P[i][0]-1)

  print(minp)


if(__name__ == '__main__'):
  main()

Solution (Python):
def resolve():
    """ recursive function"""

    def func(i, sum, cnt, rem):
        nonlocal ans
        if i == D:
            if sum < G:
                use = max(rem)
                n = min(lst[use - 1][0], -(-(G - sum) // ((use) * 100)))
                sum += n * use * 100
                cnt += n
            if sum >= G:
                ans = min(ans, cnt)
        else:
            func(i + 1, sum, cnt, rem)
            func(
                i + 1,
                sum + lst[i][0] * (i + 1) * 100 + lst[i][1],
                cnt + lst[i][0],
                rem - {i + 1})

    D, G = map(int, input().split())
    lst = [list(map(int, input().split())) for x in range(D)]
    ans = float('inf')

    func(0, 0, 0, set(range(1, D + 1)))
    print(ans)

if __name__ == "__main__":
    resolve()

Solution (Python):



from collections import defaultdict
import sys, heapq, bisect, math, itertools, string, queue, datetime






sys.setrecursionlimit(10 ** 8)
INF = float('inf')

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

for bit in range(1 << D):
    count = 0
    sum = 0
    left_over = set(range(1, D + 1))

    for i in range(D):
        if bit & (1 << i):
            sum += PC[i][0] * (i + 1) * 100 + PC[i][1]
            count += PC[i][0]
            left_over.discard(i + 1)

    if sum < G:
        use = max(left_over)
        n = min(PC[use - 1][0], -(-(G - sum) // (use * 100)))
        count += n
        sum += n * use * 100

    if sum >= G:
        ans = min(ans, count)

print(ans)

Solution (Python):


D, G = map(int, input().split())
p, c = [], []
ans = float('inf')
for _ in range(D):
    a, b = map(int, input().split())
    p.append(a)
    c.append(b)

for bit in range(1 << D):  
    score = 0
    cnt = 0
    comp = set(range(D))
    for i in range(D):  
        if bit & (1 << i):
            score += p[i] * 100 * (i + 1) + c[i]
            cnt += p[i]
            comp.discard(i)
    if score < G:  
        incomp = max(comp)
        
        
        incomp_num = min(p[incomp],
                         -(-(G - score) // (100 * (incomp + 1))))  
        score += (incomp + 1) * incomp_num * 100
        cnt += incomp_num
    if score >= G:  
        ans = min(ans, cnt)
print(ans)

Solution (Python):
def solve(bit):
    ret = 0
    score = 0
    done = set()
    for i in range(D):
        if bit[i]:
            done.add(i)
            ret += L[i][0]
            score += ((i + 1) * 100) * L[i][0] + L[i][1]
    j = D - 1
    cnt = 0
    while score < G:
        while j in done:
            j -= 1
        ret += 1
        cnt += 1
        score += (j + 1) * 100
        if cnt == L[j][0]:
            done.add(j)
            score += L[j][1]
            cnt = 0
    return ret

D, G = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(D)]
ans = float('inf')
for i in range(1 << D):
    bit = [0] * D
    for j in range(D):
        if i >> j & 1:
            bit[j] = 1
    ans = min(ans, solve(bit))
print(ans)

Solution (Python):


D, G = map(int, input().split())
p, c = [], []
ans = float('inf')
for _ in range(D):
    a, b = map(int, input().split())
    p.append(a)
    c.append(b)

for bit in range(1 << D):  
    score = 0
    cnt = 0
    comp = set(range(D))
    for i in range(D):  
        if bit & (1 << i):
            score += p[i] * 100 * (i + 1) + c[i]
            cnt += p[i]
            comp.discard(i)
    if score < G:  
        incomp = max(comp)
        incomp_num = min(p[incomp],
                         -(-(G - score) // (100 * (incomp + 1))))
        score += (incomp + 1) * incomp_num * 100
        cnt += incomp_num
    if score >= G:  
        ans = min(ans, cnt)
print(ans)

Solution (Python):
import sys
readline = sys.stdin.readline

D,G = map(int,readline().split())
P = [0] * D
C = [0] * D
for i in range(D):
  P[i],C[i] = map(int,readline().split())



ans = 10 ** 9
for i in range(2 ** D):

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

  rest = G - score


  
  if rest <= 0:
    if ans > solve:
      ans = solve
    continue
  for j in range(D - 1,-1,-1):
    if (i >> j) & 1 == 0:
      if (P[j] - 1) * (j + 1) * 100 == rest:
        solve += (P[j] - 1)
        rest = 0
        break
      if (P[j] - 1) * (j + 1) * 100 < rest:
        rest -= (P[j] - 1) * (j + 1) * 100
        solve += (P[j] - 1)
      else:
        p = (j + 1) * 100

        solve += (rest + p - 1) // p
        rest = 0
        break
  if rest > 0:
    continue
  if solve < ans:
    ans = solve

    
print(ans)

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


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

ans = float("inf")
dfs(0, 0, 0, set(range(1, d+1)))
print(ans)

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

probs.reverse()


def tobin(x, n):
    return format(x, 'b').zfill(n)

ans = 1e9
for i in range(2**d):
    s = tobin(i,d)
    comp = [c=="1" for c in s]
    tmp = 0
    cos = 0
    for j in range(d):
        if comp[j]:
            tmp += probs[j][0]*(d-j)*100+probs[j][1]
            cos += probs[j][0]

    for j in range(d):
        if comp[j]:
            continue
        else:
            if tmp < g:
                mc = (probs[j][0]-1)*(d-j)*100

                if mc + tmp >= g:
                    rest = g-tmp
                    cos += (g-tmp)//((d-j)*100)
                    if (g-tmp)%((d-j)*100) == 0:
                        break
                    else:
                        cos += 1
                        break
                else:
                    cos += probs[j][0]
                    tmp += mc
            else:
                break
    if ans > cos:
        ans = cos

print(ans)

Solution (Python):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []


def main():
    d, g = i_map()
    num_list = i_row_list(d)

    min_count = INF
    for bit in list(product([0,1], repeat=d)):
        tmp_score = 0
        tmp_count = 0
        max_i = -1
        for i in range(d):
            if bit[i] == 0:
                max_i = max(max_i, i)
                continue
            tmp_score += num_list[i][0] * 100 * (i+1) + num_list[i][1]
            tmp_count += num_list[i][0]
        if tmp_score < g:
            for _ in range(num_list[max_i][0]):
                tmp_score += 100 * (max_i+1)
                tmp_count += 1
                if tmp_score >= g:
                    break
        if tmp_score >= g:
            min_count = min(min_count, tmp_count)
        
    print(min_count)

if __name__ == '__main__':
    main()

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

sc=0
l=[]
for i in range(2**d):
  bag=[0]*d
  
  for j in range(d):
    if ((i>>j) & 1):
      bag[j]=100*(j+1)
  else:
    
    sc=0
    inc=0
    
    for ii in range(d):
      
      if bag[ii] == 0:
        continue
      sc+=bag[ii]*pc[ii][0]+pc[ii][1]
      inc+=pc[ii][0]
      if sc>=g:
        l.append(inc)
        break
      
    for index,ii in enumerate(reversed(bag)):
      
      if ii != 0:
        continue
      
      else:
        for _ in range(1,pc[index][0]):
          sc+=100*(d-index)
          inc+=1
          if sc>=g:
            l.append(inc)
            
        break

print(min(l))

Solution (Python):
d,g = map(int,input().split())
pc = []
for i in range(d):
    p,c = map(int,input().split())
    pc.append((p,c))
minimum = 2000
for i in range(2**d):
    count = 0
    remain = g
    for j in range(d):
        if i >> j & 1:
            count += pc[j][0]
            remain -= (j+1)*100*pc[j][0]
            remain -= pc[j][1]
    highest = d*100
    while remain > 0 and highest >= 100:
        if not i >> (highest//100-1) & 1:
            if highest * pc[highest//100-1][0] >= remain:
                count += -(-remain//highest)
                remain -= -(-remain//highest)*highest
            else:
                count += pc[highest//100-1][0]
                remain -= pc[highest//100-1][0]*highest
        highest -= 100
    if remain <= 0:
        minimum = min(minimum,count)
print(minimum)

Solution (Python):
def IL(): return list(map(int, input().split()))
d, g = IL()
p = [0] * d
c = [0] * d
cpl = [False] * d
ans = 10000
for i in range(d):
    p[i], c[i] = IL()
for i in range(2 ** d):
    cnt = 0
    score = 0
    cpl = [False] * d
    for j in range(d):
        if i >> j & 1:
            cpl[j] = True
    for j in range(d): 
        if cpl[j]:
            cnt += p[j]
            score += 100 * (j + 1) * p[j] + c[j]
    if score >= g:
        if cnt < ans:
            ans = cnt
        continue
    for j in reversed(range(d)): 
        if not cpl[j]:
            for k in range(p[j] - 1):
                cnt += 1
                score += 100 * (j + 1)
                if score >= g:
                    if cnt < ans:
                        ans = cnt
                    break
            else:
                continue
            break
print(ans)

Solution (Python):

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

min_problem = sum(p)

for bit in range(2**D):
    base_score = 0
    base_problem = 0
    non_completed_index = []
    for shift in range(D):
        if (bit>>shift)&1:
            base_score += c[shift]
            base_score += 100*(shift+1)*p[shift]
            base_problem += p[shift]
        else:
            non_completed_index.append(shift)

    if base_score >= G:
        if base_problem < min_problem:
            min_problem = base_problem
    else:
        add_score = 0
        add_problem = 0
        
        non_completed_index = non_completed_index[::-1]
        for idx in non_completed_index:
            max_add_score_idx = 100*(idx+1)*(p[idx]-1)
            if base_score+add_score+max_add_score_idx >= G:
                
                if (G-base_score-add_score) % (100*(idx+1)) == 0:
                    idx_problem = int((G-base_score-add_score)/(100*(idx+1)))
                else:
                    idx_problem = int((G-base_score-add_score)/(100*(idx+1)))+1
                if idx_problem+add_problem+base_problem < min_problem:
                    min_problem = idx_problem+add_problem+base_problem
                break
            else:
                add_score += max_add_score_idx
                add_problem += p[idx]-1


print(min_problem)

Solution (Python):
D, G = map(int, input().split())
P = [tuple(map(int, input().split())) for _ in range(D)]
ans = float('inf')
for bit in range(1 << D):
    score = 0
    count = 0
    rest = -1
    for i, pc in enumerate(P):
        p, c = pc
        if bit >> i & 1:
            score += 100 * (i + 1) * p + c
            count += p
        else:
            rest = i
    if score < G:
        s1 = 100 * (rest + 1)
        need = (G - score + s1 - 1) // s1
        if need >= P[rest][0]:
            continue
        count += need
    ans = min(ans, count)
print(ans)

Solution (Python):
n, m = map(int,input().split())

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

ans = 1000000000000000
for i in range(2 ** n):
    check = 0
    ac = 0
    tmp = 0
    for j in range(n):
        if (i >> j) & 1:
            check += a[j][0] * 100 * (j + 1) + a[j][1]
            tmp += a[j][0]
        
        if check >= m:
            ans = min(ans, tmp)

        else:
            for k in reversed(range(n)):
                if not (i >> k) & 1:
                    ac = -(-(m - check) // ((k + 1) * 100))
                    if ac < a[k][0]:
                        ans = min(ans, ac + tmp)

print(ans)

Solution (Python):
d, g = map(int, input().split())
p = [0 for _ in range(d)]
c = [0 for _ in range(d)]
for i in range(d):
    p[i], c[i] = map(int, input().split())
ans = -1
for pat in range(2**d):
    score = 0
    now = 0
    l = []
    for i in range(d):
        if pat & (2 ** i):
            l.append(i)
            score += 100*(i+1)*p[i]+c[i]
            now += p[i]
    if score < g:
        maxidx = None
        for i in range(d-1, -1, -1):
            if not i in l:
                maxidx = i
                break
        if maxidx == None:
            continue
        if score+100*(maxidx+1)*(p[maxidx]-1) < g:
            continue
        for i in range(p[maxidx]-1):
            score += 100*(maxidx+1)
            now += 1
            if score >= g:
                break
    if ans == -1 or ans > now:
        ans = now
print(ans)

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)

res = 1 << 29
for bit in range(1 << D):
    score, num = 0, 0
    for i in range(D):
        if bit >> i & 1: 
            score += c[i] + p[i] * 100 * (i + 1)
            num += p[i]
    if score >= G:
        res = min(res, num)
    else:
        for j in range(D - 1, -1, -1):
            if bit >> j & 1: 
                continue
            for k in range(p[j]):
                if score >= G:
                    break
                score += 100 * (j + 1)
                num += 1
        res = min(res, num)
print(res)

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)

from itertools import product
res = 1 << 29
for v in product([0, 1], repeat=D):
    score, num = 0, 0
    for i in range(D):
        if v[i] == 1:
            score += c[i] + p[i] * 100 * (i + 1)
            num += p[i]
    if score >= G:
        res = min(res, num)
    else:
        for j in range(D - 1, -1, -1):
            if v[j] == 1:
                continue
            for k in range(p[j]):
                if score >= G:
                    break
                score += 100 * (j + 1)
                num += 1
        res = min(res, num)
print(res)

Solution (Python):
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
	D, G = NMI()
	problems = [NLI() for _ in range(D)]
	n = D
	ans = 10**10
	for case in range(2 ** n):
		res = 0
		point = 0
		maxbit = 0
		for i in range(n):
			if (case >> i) & 1:
				res += problems[i][0]
				point += problems[i][1] + problems[i][0] * (i+1) * 100
			else:
				maxbit = max(maxbit, i)
				pass

		if point >= G:
			ans = min(ans, res)
			continue

		for i in range(problems[maxbit][0]):
			point += (maxbit+1) * 100
			res += 1
			if point >= G:
				ans = min(ans, res)
				break

	print(ans)


if __name__ == "__main__":
	main()

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

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







D, G = getNM()
query = []
for i in range(D):
    p, c = getNM()
    query.append([i + 1, p, c])

ans_cnt = float('inf')

for bit in range(1 << D):
    sum = 0
    cnt = 0
    for i in range(D):
        if bit & (1 << i):
            sum += query[i][0] * query[i][1] * 100 + query[i][2]
            cnt += query[i][1]

    if sum < G:
        for j in range(D - 1, -1, -1):
            if not bit & (1 << j):
                left = G - sum
                fire = query[j][0] * 100
                opt = min(query[j][1], (left + fire - 1) // fire)
                sum += opt * query[j][0] * 100
                cnt += opt
                break

    if sum >= G:
        ans_cnt = min(ans_cnt, cnt)

print(ans_cnt)

Solution (Python):
def solve(D, G, P, C):
    ret = float('inf')
    for i in range(pow(2, D)):
        tmp_score = 0
        tmp_counter = 0
        not_selected = -1

        for j in range(D):
            if i >> j & 1:
                tmp_counter += P[j]
                tmp_score += P[j] * 100 * (j + 1) + C[j]
            else:
                not_selected = j

        if G <= tmp_score:
            ret = min(ret, tmp_counter)
            continue

        for _ in range(1, P[not_selected]):
            tmp_score += 100 * (not_selected + 1)
            tmp_counter += 1
            if G <= tmp_score:
                ret = min(ret, tmp_counter)
                break

    print(ret)

if __name__ == "__main__":
    D, G = map(int, input().split())
    P = []
    C = []

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

    solve(D, G, P, C)

Solution (Python):
def solve(D, G, P, C):
    ret = float('inf')
    for i in range(pow(2, D)):
        selected = []
        tmp_score = 0
        tmp_counter = 0
        not_selected = -1

        for j in range(D):
            if i >> j & 1:
                selected.append(j)
                tmp_counter += P[j]
                tmp_score += P[j] * 100 * (j + 1) + C[j]
            else:
                not_selected = j

        if G <= tmp_score:
            ret = min(ret, tmp_counter)
            continue

        for _ in range(1, P[not_selected]):
            tmp_score += 100 * (not_selected + 1)
            tmp_counter += 1
            if G <= tmp_score:
                ret = min(ret, tmp_counter)
                break

    print(ret)

if __name__ == "__main__":
    D, G = map(int, input().split())
    P = []
    C = []

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

    solve(D, G, P, C)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


def main():
    D, G = map(int, input().split())
    question = []
    bonus = []
    for i in range(D):
        p, c = map(int, input().split())
        question.append(p)
        bonus.append(c)

    """
    決め打ち二分探索と思い込んで「x問解いて得られる最大得点」を出そうとして撃沈。。。
    結局その発想をしたところで、肝は
        ・どのボーナスを得るか
        ・ボーナスを取らない「唯一の」得点群はどれか
    なので、それなら初めからこれに着目して問題を解いたうえで、それが得点Gを超えるかどうか
    確かめた方が早い。
    """ 

    ans = sum(question)
    for state in range(1 << D):
        
        score = 0
        num = 0
        solved = set([])
        for i in range(D):
            if state & (1 << i):
                solved.add(i)
                num += question[i]
                score += 100 * (i + 1) * question[i] + bonus[i]
        if score >= G:
            ans = min(ans, num)
            continue

        
        last_idx = D - 1
        while last_idx in solved: last_idx -= 1
        for i in range(question[last_idx]):
            score += 100 * (last_idx + 1)
            num += 1
            if score >= G:
                ans = min(ans, num)
                break
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import math
import sys
from collections import deque
a,b=map(int,input().split())
l=[list(map(int,input().split())) for i in range(a)]
ans=10**20
for i in range(2**a):
  s=0
  count=0
  keep1=0
  keep2=0
  t=True
  for j in range(a):
    if i>>j &1:
      s+=l[a-1-j][0]*100*(a-j)+l[a-1-j][1]
      count+=l[a-1-j][0]
    else:
      if t:
        keep1=100*(a-j)
        keep2=l[a-1-j][0]-1
        t=False
  if s+keep1*keep2>=b:
    if s>=b:
      if ans>count:
        ans=count
    else:
      p=count+math.ceil((b-s)/keep1)
      if p<ans:
        ans=p
print(ans)

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

ans =  float('inf')


for bit in range(1 << D ):
    sum = 0
    count = 0
    nokori = set(range(1, D + 1))

    for i in range(D):
        
        
        if bit & (1 << i):
            sum +=  100 * (i + 1) * pi[i] + ci[i]
            count += pi[i]
            nokori.discard(i + 1)

    if (sum < G ):
        use = max(nokori)
        n = min(pi[use-1], (G- sum )// (use * 100) )
        if n < 1:
            n = 1
        count += n
        sum   += n * 100 * use 

    if  (sum >= G):
        ans = min(count, ans)

print(ans)

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

ans =  float('inf')


for bit in range(1 << D ):
    sum = 0
    count = 0
    nokori = set(range(1, D + 1))

    for i in range(D):
        
        
        if bit & (1 << i):
            sum +=  100 * (i + 1) * pi[i] + ci[i]
            count += pi[i]
            nokori.discard(i + 1)

    if (sum < G ):
        use = max(nokori)
        n = min(pi[use-1], -(-(G- sum )// (use * 100) ) )
        count += n
        sum   += n * 100 * use 

    if  (sum >= G):
        ans = min(count, ans)

print(ans)

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 sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
d, g = ri_()
p, c = [0] * d, [0] * d
for i in range(d):
    p[i], c[i] = ri_()
ans = 1000
for bit in range(1 << d):
    pro = 0
    poi = 0
    L = []
    for i in range(d):
        if bit & (1 << i):
            pro += p[i]
            poi += p[i] * (i + 1) * 100 + c[i]
        else:
            L.append(i)
    for i in L[::-1]:
        if poi < g:
            tmp = min(p[i], -(-(g - poi) // (100 * (i + 1))))
            pro += tmp
            poi += tmp * 100 * (i + 1)
        else:
            break
    if poi >= g:
        ans = min(ans, pro)
print(ans)

Solution (Python):
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)

ans = 1 << 60
for S in range(1 << D):
    score = 0
    num = 0
    for i in range(D):
        if (S >> i) & 1:
            score += cs[i] + ps[i] * 100 * (i + 1)
            num += ps[i]
    for i in reversed(range(D)):
        if not (S >> i) & 1:
            index = 0
            while score < G and index < ps[i]:
                score += 100 * (i + 1)
                num += 1
                index += 1
    if score >= G:
        ans = min(ans, num)
print(ans)

Solution (Python):


from itertools import product

d, g = map(int, input().split())
ans = 10 ** 10
PC = [list(map(int, input().split())) for _ in range(d)]
kumiawase = list(product([1, 0], repeat=d))
for kumi in kumiawase:
    cnt = 0
    temp = 0
    unused = []
    for i in range(d):
        p, c = PC[i]
        if kumi[i] == 1:
            temp += (i + 1) * 100 * p
            temp += c
            cnt += p
        else:
            unused.append(((i + 1) * 100, p))
    if temp >= g:
        ans = min(ans, cnt)
    else:
        if not unused:
            continue
        remain = g - temp
        unused.sort(reverse=True)
        saidai, kaisu = unused[0]
        if remain <= (kaisu - 1) * saidai:
            cnt += (remain + saidai - 1) // (saidai)
            ans = min(ans, cnt)

print(ans)