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. 



Sample input:
2 700
3 500
5 800


Sample output:
3

Submission status: Runtime Error

Solution code:
import itertools
from pprint import pprint
import sys 
sys.setrecursionlimit(100*10+1024)
#基本的に10*100*len(bonus_masterlist)回ループを回せばよい
#len(bonus_masterlist)は最大で2**10=1024

d,g = map(int,input().split())

plist=[]
clist=[]

bonus_masterlist=[]

for _ in range(d):
    p_temp,c_temp = map(int,input().split())
    plist.append(p_temp)
    clist.append(c_temp)


bonus_masterlist = list(itertools.product(range(2), repeat=5))
#bit全探索をやらなくても、itertoolsを使えば一瞬でできちゃう。(タプルのリスト)
#for i in range(2**d):
#    bonus_templist = [0] * d
#    for j in range(d):
#        if i >> j & 1:
#            bonus_templist[d-1-j] = 1
#    bonus_masterlist.append(bonus_templist)

#point_list = [100,200,300, ... ,d*100]
#max_list: plist = [p[0],p[1],p[2], ... ,p[d]]
#bonuspoint_list: clist = [c[0],c[1],c[2], ... ,c[d]]

count_list = [0] * d

mincount = 100 * 10

def dfs(i):
    global mincount
    if sum([count_list[i] * 100*(i+1) for i in range(d)]) + sum([bonus_list[j] * clist[j] for j in range(d)]) >= g:
        if sum(count_list) < mincount:
            mincount = sum(count_list)
    elif plist[i] == count_list[i]:
        bonus_list[i] = 1
        dfs(i-1)
    elif plist[i] > count_list[i]:
        count_list[i] += 1
        dfs(i)
    return

for bonus_tuple in bonus_masterlist:
    bonus_list = list(bonus_tuple)
    count_list = [x * y for (x, y) in zip(bonus_list, plist)]
    dfs(d-1)

print(mincount)

Submission status: Runtime Error

Solution code:
import itertools
from pprint import pprint

d,g = map(int,input().split())

plist=[]
clist=[]

bonus_masterlist=[]

for _ in range(d):
    p_temp,c_temp = map(int,input().split())
    plist.append(p_temp)
    clist.append(c_temp)


bonus_masterlist = list(itertools.product(range(2), repeat=5))
#bit全探索をやらなくても、itertoolsを使えば一瞬でできちゃう。(タプルのリスト)
#for i in range(2**d):
#    bonus_templist = [0] * d
#    for j in range(d):
#        if i >> j & 1:
#            bonus_templist[d-1-j] = 1
#    bonus_masterlist.append(bonus_templist)

#point_list = [100,200,300, ... ,d*100]
#max_list: plist = [p[0],p[1],p[2], ... ,p[d]]
#bonuspoint_list: clist = [c[0],c[1],c[2], ... ,c[d]]

count_list = [0] * d

mincount = 100 * 10

def dfs(i):
    global mincount
    if sum([count_list[i] * 100*(i+1) for i in range(d)]) + sum([bonus_list[j] * clist[j] for j in range(d)]) >= g:
        if sum(count_list) < mincount:
            mincount = sum(count_list)
    elif plist[i] == count_list[i]:
        bonus_list[i] = 1
        dfs(i-1)
    elif plist[i] > count_list[i]:
        count_list[i] += 1
        dfs(i)
    return

for bonus_tuple in bonus_masterlist:
    bonus_list = list(bonus_tuple)
    count_list = [x * y for (x, y) in zip(bonus_list, plist)]
    dfs(d-1)

print(mincount)

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(x) for x in input().split()]

a.sort()
ans=0
for i in range(n//2):
  ans -= a[i]*(n-1-i)
  ans += a[-i-1]*(n-1-i*2)
  
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import product

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

comp_abv_G = 10000
comp_abv_score = 0
comp_abv_list = []
exceed_G = 10000
exceed_score = 0

for comp_list in product((0, 1), repeat=D):
    score = 0
    solved = 0
    for n, i in enumerate(comp_list):
        if i == 1:
            score += PC[n][1] + PC[n][0]*(n+1)*100
            solved += PC[n][0]
    #print(score, solved)
#    if comp_abv_score < score <= G and comp_abv_score/comp_abv_G < score/solved:
    if score <= G:
        temp_idx = len(comp_list)-1 - comp_list[::-1].index(0)
        if G - score <= ((temp_idx + 1) * 100) * PC[temp_idx][0]:
            if solved != 0 and comp_abv_score/comp_abv_G < score/solved:
                comp_abv_G = solved
                comp_abv_score = score
                comp_abv_list = comp_list
                #print(comp_list, comp_abv_score, comp_abv_G)
    elif solved != 0:
        if score >= G and exceed_G > solved:
            exceed_G = solved
            exceed_score = score

if comp_abv_score == G:
    #print(comp_abv_G)
    exit()
#elif len(comp_abv_list) == 0:
#    print(exceed_G)
#    exit()
if len(comp_abv_list) == 0:
    comp_abv_list = [0 for i in range(D)]
    comp_abv_G = 0

cand_solved = 10000
for n, i in enumerate(comp_abv_list):
    if i == 0:
        temp = comp_abv_list
        temp_score = comp_abv_score
        temp_solved = comp_abv_G
        #print(temp, temp_score, temp_solved)

        k = ((G - temp_score) % ((n + 1) * 100))
        #print(k)
        if k == 0:
            #print(n)
            temp_solved += ((G - temp_score) //
                            ((n + 1) * 100))
        else:
            temp_solved += 1 + ((G - temp_score) //
                            ((n + 1) * 100))
        if cand_solved > temp_solved:
            cand_solved = temp_solved

print(min(exceed_G, cand_solved))

Submission status: Runtime Error

Solution code:
from itertools import product

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

comp_abv_G = 10000
comp_abv_score = 0
comp_abv_list = []
exceed_G = 10000
exceed_score = 0

for comp_list in product((0, 1), repeat=D):
    score = 0
    solved = 0
    for n, i in enumerate(comp_list):
        if i == 1:
            score += PC[n][1] + PC[n][0]*(n+1)*100
            solved += PC[n][0]
    #print(score, solved)
#    if comp_abv_score < score <= G and comp_abv_score/comp_abv_G < score/solved:
    if score <= G:
        temp_idx = len(comp_list)-1 - comp_list[::-1].index(0)
        if G - score < ((temp_idx + 1) * 100) * PC[temp_idx][0]:
            if solved != 0 and comp_abv_score/comp_abv_G < score/solved:
                comp_abv_G = solved
                comp_abv_score = score
                comp_abv_list = comp_list
                #print(comp_list, comp_abv_score, comp_abv_G)
    elif solved != 0:
        if score >= G and exceed_G > solved:
            exceed_G = solved
            exceed_score = score

if comp_abv_score == G:
    #print(comp_abv_G)
    exit()
#elif len(comp_abv_list) == 0:
#    print(exceed_G)
#    exit()
if len(comp_abv_list) == 0:
    comp_abv_list = [0 for i in range(D)]
    comp_abv_G = 0

cand_solved = 10000
for n, i in enumerate(comp_abv_list):
    if i == 0:
        temp = comp_abv_list
        temp_score = comp_abv_score
        temp_solved = comp_abv_G
        #print(temp, temp_score, temp_solved)

        k = ((G - temp_score) % ((n + 1) * 100))
        #print(k)
        if k == 0:
            #print(n)
            temp_solved += ((G - temp_score) //
                            ((n + 1) * 100))
        else:
            temp_solved += 1 + ((G - temp_score) //
                            ((n + 1) * 100))
        if cand_solved > temp_solved:
            cand_solved = temp_solved

print(min(exceed_G, cand_solved))

Submission status: Runtime Error

Solution code:
D, G = map(int, input().split())
grid = [[0,0]]#インデックス合わせとく
for i in range(D):
    p,c = map(int, input().split())
    grid.append([p,c])

import itertools
kumi = list(itertools.product([0,1], repeat=D))
anls = []
fans = float('inf')
for item in kumi:
    count = 0
    ans = 0
    k = 0
    score = 0
    for i in item:
        count += 1
        if i == 1:
            score += grid[count][0]*100*count + grid[count][1]
            ans += grid[count][0]
        else:
            k = count

    if G <= score :
        fans = min(fans,ans)
    elif score+(k*100)*(grid[k][0]-1) >= G :
        a = int((G-score)/(k*100))
        if score+a*k*100=G:
            ans += a
        else:
            ans += (a+1)
        fans = min(fans,ans)
if fans != float('inf'):
    fans = int(fans)
print(fans)

Submission status: Runtime Error

Solution code:
D, G = map(int, input().split()) 
S = [[int(x) for x in input().split()]for i in range(D)]
Minimum_can = []
for i in range(2**D-1):
    binary = str(format(i,'b'))
    binary_zero = binary.zfill(D)
    SUM = 0
    Number = 0
    for j in range(D):
        if binary_zero[j]=='1':
            SUM += S[j][0]*100*(j+1)+S[j][1]
            Number += S[j][0]
    if SUM == G: Minimum_can.append(Number)        
    elif SUM < G:
        Biggest_0_number = 0
        for k in range(D):
            if binary_zero[D-k-1]=='0':
                Biggest_0_number = D-k-1
                break
        for k in range(S[Biggest_0_number][0]):
            if SUM+100*(Biggest_0_number+1)*(k+1) >= G:
                Minimum_can.append(Number+k+1)
                break 
print(min(Minimum_can))

Submission status: Runtime Error

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

ans = float("inf")
for i in range(2**D):
    sum = 0
    count = 0
    rem = set(range(1,D+1))
    for j in range(D):
        if (i >> j) & 1:
            sum += pc[j][0]*100*j+pc[j][1]
            count += pc[j][0]
            rem.discard(j+1)
    if sum < G:
        k = max(rem)-1
        n = min(pc[k][0],-(-(G-sum)//((k+1)*100))
        count += n
        sum += n*100*(k+1)
    if sum >= G:
        ans = min(ans,count)

print(ans)

Submission status: Runtime Error

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

P = []
C = []
for i in range(D):
  tempP, tempc = map(int, input().split())
  P.append(tempP)
  C.append(tempC)

print(P,C)

Submission status: Runtime Error

Solution code:
d,g = map(int, input().split())
pd = [[int(i) for i in input().split()] for _ in range(d)]

ans = inf
for mask in range(1 << d):
  tmp = 0
  tmp1 = 0
  for j in range(d):
    if 1 << j & mask:
      tmp += pd[j][1]
      tmp += pd[j][0] * 100 * (j + 1)
      tmp1 += pd[j][0]
  for j in range(d-1,-1,-1):
    if not(1 << j & mask):
      if tmp + pd[j][0] * 100 * (j + 1) >= g:
        tmp = g
        tmp1 += (g - tmp) // (100 * (j + 1))
        break
      tmp1 += pd[j][0]
      tmp += pd[j][0] * 100 * (j + 1)
  if tmp >= g:
    ans = min(ans, tmp1)
print(ans)

Submission status: Runtime Error

Solution code:
D,G = map(int,input().split())
l = list(list(map(int, input().split())) for _ in range(D))

#得点の大きい順に並び替えておく
l = l[::-1]

ans = float("inf")
for i in range(2**D):
    total = 0
    cnt = 0
    for j in range(D):
      
    if (i>>j)&1:
            total += 100*(D-j)*l[j][0] + l[j][1]
            cnt += l[j][0]
    if total >= G:
        ans = min(ans,cnt)
        continue
    for j in range(D):
        if (i>>j)&1 == False:
            for k in range(l[j][0]):
                total += 100*(D-j)
                cnt+=1
                if total >= G:
                    ans = min(ans,cnt)
                    break
            break

print(ans)

Submission status: Runtime Error

Solution code:
D,G = map(int,input().split())
l = list(list(map(int, input().split())) for _ in range(D))

l = l[::-1]

ans = float("inf")
for i in range(2**D):
    total = 0
    cnt = 0
    for j in range(D):
      
    if (i>>j)&1:
            total += 100*(D-j)*l[j][0] + l[j][1]
            cnt += l[j][0]
    if total >= G:
        ans = min(ans,cnt)
        continue
    for j in range(D):
        if (i>>j)&1 == False:
            for k in range(l[j][0]):
                total += 100*(D-j)
                cnt+=1
                if total >= G:
                    ans = min(ans,cnt)
                    break
            

print(ans)

Submission status: Runtime Error

Solution code:
D,G = map(int,input().split())
l = list(list(map(int, input().split())) for _ in range(D))

#得点の大きい順に並び替えておく
l = l[::-1]

ans = float("inf")
for i in range(2**D):
    total = 0
    cnt = 0
    for j in range(D):
      
    if (i>>j)&1:
            total += 100*(D-j)*l[j][0] + l[j][1]
            cnt += l[j][0]
    if total >= G:
        ans = min(ans,cnt)
        continue
    for j in range(D):
        if (i>>j)&1 == False:
            for k in range(l[j][0]):
                total += 100*(D-j)
                cnt+=1
                if total >= G:
                    ans = min(ans,cnt)
                    break
            #break

print(ans)

Submission status: Runtime Error

Solution code:
import math

def resolve():
	d, g = map(int, input().split())
	ps = []
	cs = []
	ans = math.inf
	for _ in range(d):
		p, c = map(int, input().split())
		ps.append(p)
		cs.append(c)
	for i in range(d-1, -1, -1):
		total = 0
		solved = 0
		for _ in range(ps[i]):
			if total >= g:
				if ans > solved:
					ans = solved
				break
			total += 100 * (i + 1)
			solved += 1
		total += cs[i]
		if total >= g and ans > solved:
			ans = solved
			break
		for j in range(d-1, -1, -1):
			if i == j:
				continue
			for _ in range(ps[j]):
				if total >= g:
					if ans > solved:
						ans = solved
					continue
				total += 100 * (j+1)
				solved += 1
			total += cs[j]
	print(ans)
resolve()

Submission status: Runtime Error

Solution code:
a,g = map(int,input().split())
li = []
ans = []
for i in range(a):
  pc = list(map(int,input().split()))
  li.append(pc)
for bit in range(1<<a):
  p = 0
  pt = 0
  c = 0
  for i in range(a):
    if ((bit >> i) & 1):
      p += li[i][0]
      pt += 100*(i+1)*li[i][0] + li[i][1]
  if pt >= g:
    ans.append(p)
  else:
    for j in range(d-1,-1,-1):
      if ((bit >> j) & 1) == 0:
        for k in range(li[j][0]):
          if pt >= g:
            break
          c += 1
          p += 1
          pt += 100*(j+1)
    ans.append(p)
          
print(min(ans))

Submission status: Runtime Error

Solution code:
def dfs(i, sum, count, nokori):
    global ans
    if i == d:
        # G 点に満たなければ nokori のうち一番大きいものを解く
        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)

Submission status: Runtime Error

Solution code:
    D,G = map(int,input().split())
    G /= 100
    G=int(G)
    vec = list(list(map(int,input().split())) for i in range(D))
    for i in range(D):
        vec[i][1] /= 100
        vec[i][1] = int(vec[i][1])
        
    dp = [[10**7 for i in range(G+1)] for j in range(D+1)]
    dp[0][0] = 0
    for i in range(D):
        for j in range(G+1):
            for k in range(vec[i][0]+1):
                posit = min(j+(i+1)*k,G)
                if(k == vec[i][0]):
                    posit += vec[i][1]
                    posit = min(G,posit)
                dp[i+1][posit] = min(dp[i][posit], dp[i][j] + k,dp[i + 1][posit])
            for k in reversed(range(G)):
                if(dp[i+1][k] == 10**7):
                    dp[i+1][k] = dp[i+1][k]
    print(dp[D][G])

Submission status: Runtime Error

Solution code:
num, target = map(int, input().split())
qlist = []
qmaxtuple = []
for i in range(num):
    qlist.append(list(map(int, input().split())))
dstnum = float("infinity")
for i in range(num):
    qnum = qlist[i-1][0]
    qmax = i*100*qnum+qlist[i-1][1]
    qmaxtuple.append((qmax, qnum, i-1))
qmaxtuple.sort(key=lambda k: k[0]/k[1])
_dst = 0
while max(qmaxtuple)[0] < target:
    temp = qmaxtuple.pop()
    target -= temp[0]
    _dst += temp[1]
    del qlist[temp[2]]
for i in range(len(qlist)-1, -1, -1):
    for k in range(qlist[i][0]):
        if (i+1)*100*k >= target:
            if dstnum > k:
                dstnum = k
            break
    else:
        if (i+1)*100*k+qlist[i][1] >= target:
            if dstnum > k:
                dstnum = k
dst = dstnum + _dst
print(dst)

Submission status: Runtime Error

Solution code:
num, target = map(int, input().split())
qlist = []
qmaxtuple = []
for i in range(num):
    qlist.append(list(map(int, input().split())))
dstnum = float("infinity")
for i in range(num):
    qnum = qlist[i-1][0]
    qmax = i*100*qnum+qlist[i-1][1]
    qmaxtuple.append((qmax, qnum, i-1))
qmaxtuple.sort(key=lambda k: k[0]/k[1])
_dst = 0
while max(qmaxtuple)[0] < target:
    temp = qmaxtuple.pop()
    target -= temp[0]
    _dst += temp[1]
    del qlist[temp[2]]
for i in range(len(qlist)-1, -1, -1):
    for k in range(qlist[i][0]):
        if (i+1)*100*k >= target:
            if dstnum > k:
                dstnum = k
            break
    else:
        if i*100*k+qlist[i-1][1] >= target:
            if dstnum > k:
                dstnum = k
dst = dstnum + _dst
print(dst)

Submission status: Runtime Error

Solution code:
D,G = map(int,input().split())
P=[]
C=[]
for _ in range(D):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)
anss=2**10
for i in range(1 << D):
    ans = 0
    summ = 0
    nokori = set(range(1,D+1))
    for j in range(D):
        if 1 & (i >> j):
            summ += P[j]*100*(j+1)+C[j]
            ans += P[j]
            nokori.discard(j+1)
    if summ < G:
        use = max(nokori)
        n = min(P[use-1],-((G-summ)//(100*use)))
        ans += n
        summ += n* use* 100

    if summ < G:
        summ+=C[use-1]

    if summ >= G:
        anss =min(ans,anss)
        
print(anss

Submission status: Runtime Error

Solution code:
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]
ans = []
for i in range(2**d):
    tmp = 0
    cnt = 0
    gg = g 
    bag = []
    for j in range(d):
        if (i>>j)&1:
            # すべて解く
            tmp += 100*(j+1)*pc[j][0] + pc[j][1]
            cnt += pc[j][0]
            bag += [j]

    if tmp > gg:
        ans += [cnt]
    else:
        gg -= tmp 
        for j in range(d-1, -1, -1):
            if j not in bag:
                c = (gg-1)//(100*(j+1))+1
                if 0 <= c <= pc[j][0]:
                    gg -= 100*(j+1)*c + pc[j][1]
                    cnt += c 
                if gg <= 0:
                    ans += [cnt]
                    break
        
print(min(ans))

Submission status: Runtime Error

Solution code:
from collections import deque
import itertools
d,g = list(map(int,input().split()))
pc = [list(map(int,input().split())) for _ in range(d)]
g /= 100

pat = list(itertools.permutations(range(d)))
ans = sum([[x,y] for x,y in zip(pc[0], pc[1])][0])

def dfs(k, point, cnt, pat):
  global ans
  i = pat[k]
  
  for j in range(pc[i][0]):
      point += (i+1)
      cnt += 1
      if j == pc[i][0]-1:
        point += pc[i][1]//100
      
      if point >= g:
        ans = min(ans, cnt)
        point = 0
        cnt = 0
        break
    
  if k < d-1:
    dfs(k+1, point, cnt, pat)

for p in pat:
  dfs(0, 0, 0, list(p))

print(ans)

Submission status: Runtime Error

Solution code:
from collections import deque
import itertools
d,g = list(map(int,input().split()))
pc = [list(map(int,input().split())) for _ in range(d)]
g /= 100

pat = list(itertools.permutations(range(1,d+1)))
ans = sum([[x,y] for x,y in zip(pc[0], pc[1])][0])

def dfs(k, point, cnt, pat):
  global ans
  i = pat[k]
  for j in range(pc[i-1][0]):
    point += i
    cnt += 1
    if j == pc[i-1][0]-1:
      point += pc[i-1][1]/100
    #print(i,j,point,cnt)
    if point >= g:
      ans = min(ans, cnt)
      point = 0
      cnt = 0
      break
  
  if k < d-1:
    dfs(k+1, point, cnt, pat)
    
for p in pat:
  #print(p)
  dfs(0,0,0,list(p))

print(ans)

Submission status: Runtime Error

Solution code:
  n,k = [int(i) for i in input().split()]
  pg = []
  for i in range(n):
    array = list(map(int,input().split()))
    pg.append(array)
  l = []

  for i in range(n):
    line = [int(j)*100*(i+1) for j in range(pg[i][0])]
    line.append(pg[i][0]*100*(i+1)+pg[i][1])
    l.append(line)

  chk = []
  chk_append = chk.append
  def f(a,b,c):
    if a == n:
      chk_append([b,c])
    else:
      return [f(a+1,b+l[a][i],c+i) for i in range(len(l[a]))]
  f(0,0,0)

  ans = []
  ans_append = ans.append
  for i in chk:
    if i[0] >= k:
      ans_append(i[1])
  print(min(ans))

Submission status: Runtime Error

Solution code:
import copy
import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)
 
m = 10**9
def score(point = 0, n = 0, now=0, done=[]):
    global m
    if point >= g:
        if m > n: m = n
    elif point+100*(now+1)*P[now] >= g:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: 
            m = n
    else:
        done.append(now)
        for i in range(d):
            if not i in done:
                score(point+P[now]*100*(now+1) + C[now], n + P[now], i, done.copy()
 
for i in range(d):
    done = []
    score(0,0,i,done)
print(m)

Submission status: Runtime Error

Solution code:
d,g = map(int,input().split() )
l = [list(map(int,input().split() ))+[100*(x+1)] for x in range(d) ] 

mondai_num = []

for k in range(2**d):

  #先に全完するカテゴリ(何百点問題を全完するか)を決め、回す
  bin_str = format(k, "0{}b".format(d) )#二進数の文字列を取得
  #これが全完する問題のリスト
  zenkan_list = [ x.start() for x in re.finditer("1",bin_str)  ] 
  

  #0~9のリストと和の初期化
  d_list = [i for i in range(d)]
  wa = 0
  cnt = 0
  #全完した点数のみ先に足す
  for i in zenkan_list:
    wa = wa+(l[i][0])*((i+1)*100)
    wa = wa + l[i][1]  
    cnt = cnt + l[i][0]
  #全完したやつだけで目標を超えたらそこでストップ
  if wa>=g:
    mondai_num.append( cnt )

  #全完したやつだけでたらなかったら素点が大きいやつを全完一歩手前まで足す
  else:
    #全完したカテゴリを除外
    for i in zenkan_list:
      d_list.remove(i)
    #残ったカテゴリの中で最大の点数のカテゴリを探す
    max_set = l[max(d_list)]

    for i in range( max_set[0]  ):
      wa = wa + max_set[2]
      if wa >= g:
        mondai_num.append(cnt + i+1 )
        break
print(min(mondai_num))

Submission status: Runtime Error

Solution code:
import sys
import itertools
input = sys.stdin.readline

d, g = map(int, input().split())
pc = []
ans = []
bit = list(itertools.product([0, 1], repeat=d))
cnt_v = 0
cnt = 0

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

for i in range(2 ** d):
    for j in range(d):
        if bit[i][j] == 1:
            p = pc[j][0]
            c = pc[j][1]
            p_index = j + 1
            cnt_v += p * 100 * p_index + c
            cnt += p

    for j in range(d):
        cnt_check = cnt_v
        if bit[i][j] == 0:
            p = pc[j][0]
            p_index = j + 1

            for k in range(p):
                if cnt_check >= g:
                    cnt += k
                    ans.append(cnt)
                    cnt -= k
                    break

                cnt_check += 100 * p_index
    cnt = 0
    cnt_v = 0

print(min(ans))

Submission status: Runtime Error

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

ans = 1e9
for mask in range(2**D - 1):
  score = 0
  num = 0
  rest_max = -1

  for i in range(D):
    if (mask >> i) & 1:
      score += 100 * (i+1) * P[i] + C[i]
      num += P[i]
    else:
      rest_max = i

  #print('mask {}, score {}, num {}, rest_max {}'.format(format(mask, '010b'), score, num, rest_max))

  if score < G:
    scr1 = 100 * (rest_max + 1)
    need = (G - score + scr1 - 1) // scr1
    if need >= P[rest_max]:
      #print('fault')
      continue
    num += need
    #print('追加 {}, 合計 {}'.format(need, num))
  else:
    #print('合計 {}'.format(num))

  ans = min(ans, num)

print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

[D, G] = [int(i) for i in input().split()]

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

points = []
for i in range(len(P)):
    points.extend([100 * (i+1)] * P[i])

def dfs(i, total, problem_number, solved_P):
    #print('i: {}'.format(i))
    if i >= len(points):
        return len(points)
    
    # points[i]を使わない場合
    unused = dfs(i + 1, total, problem_number, solved_P[:])

    # points[i]を使う場合
    #print('kita')
    #print(i)
    element = int(points[i] / 100) - 1
    #print(element)
    solved_P[element] += 1
    #print(solved_P)
    c = C[element] if solved_P[element] == P[element] else 0
    #print(c
    if total + points[i] + c >= G:
        #print(solved_P)
        #print(problem_number + 1)
        return problem_number + 1
    used = dfs(i + 1, total + points[i] + c, problem_number + 1, solved_P[:])

    return min(used, unused)

print(dfs(0, 0, 0, [0] * len(P)))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

[D, G] = [int(i) for i in input().split()]

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

#print(P)
#print(C)

points = []
for i in range(len(P)):
    points.extend([100 * (i+1)] * P[i])
#print(points)

def dfs(i, sum, problem_number, solved_P):
    #print('i: {}'.format(i))
    if i >= len(points):
        return len(points)
    
    # points[i]を使わない場合
    unused = dfs(i + 1, sum, problem_number, solved_P[:])

    # points[i]を使う場合
    #print('kita')
    #print(i)
    element = int(points[i] / 100) - 1
    #print(element)
    solved_P[element] += 1
    #print(solved_P)
    c = C[element] if solved_P[element] == P[element] else 0
    #print(c
    if sum + points[i] + c >= G:
        #print(solved_P)
        #print(problem_number + 1)
        return problem_number + 1
    used = dfs(i + 1, sum + points[i] + c, problem_number + 1, solved_P[:])

    return min(used, unused)

print(dfs(0, 0, 0, [0] * len(P)))

Submission status: Runtime Error

Solution code:
from itertools import product

D,G=map(int,input().split())
p,c=[],[]

for _ in range(D):
  pi,ci=map(int,input().split())
  p.append(pi)
  c.append(ci)
  
ans=10**4
  
for cpls in product((range(2),repeat=D)):
  num=0#回答数
  tensu=0#各cplsの得点
  for i,v in enumerate(cpls,start=1):
    if v==1:
      tensu+=i*100*p[i-1]+c[i-1]
      num+=p[i-1]
  if tensu>=G:
    ans=min(ans,num)
    continue
  for i,v in reversed(list(enumerate(cpls,start=1))):
    if v==0:
      for j in range(1,p[i-1]):
        tesu+=j*100*p[i-1]
        num+=1
        if tensu>=G:
          ans=min(ans,num)
          break
print(ans)

Submission status: Runtime Error

Solution code:
from intertools import product

D,G=map(int,input().split())
p,c=[],[]

for _ in range(D):
  pi,ci=map(int,input().split())
  p.append(pi)
  c.append(ci)
  
ans=10**4
  
for cpls in product((range(2),repeat=D)):
  num=0#回答数
  tensu=0#各cplsの得点
  for i,v in enumerate(cpls,start=1):
    if v==1:
      tensu+=i*100*p[i-1]+c[i-1]
      num+=p[i-1]
  if tensu>=G:
    ans=min(ans,num)
    continue
  for i,v in reversed(list(enumerate(cpls,start=1))):
    if v==0:
      for j in range(1,p[i-1]):
        tesu+=j*100*p[i-1]
        num+=1
        if tensu>=G:
          ans=min(ans,num)
          break
print(ans)

Submission status: Runtime Error

Solution code:
from intetools import product

D,G=map(int,input().split())
p,c=[],[]

for _ in range(D):
  pi,ci=map(int,input().split())
  p.append(pi)
  c.append(ci)
  
ans=10**4
  
for cpls in product((range(2),repeat=D)):
  num=0#回答数
  tensu=0#各cplsの得点
  for i,v in enumerate(cpls,start=1):
    if v==1:
      tensu+=i*100*p[i-1]+c[i-1]
      num+=p[i-1]
  if tensu>=G:
    ans=min(ans,num)
    continue
  for i,v in reversed(list(enumerate(cpls,start=1))):
    if v==0:
      for j in range(1,p[i-1]):
        tesu+=j*100*p[i-1]
        num+=1
        if tensu>=G:
          ans=min(ans,num)
          break
print(ans)

Submission status: Runtime Error

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

pre_ans = 0
ans = 0
a = 0
res = 0
x = 0

max_score = [(i+1)*100*List[i][0]+List[i][1] for i in range(n-1, -1, -1)] #全て答えたときのスコアを算出(逆順)
score = [(i+1)*100 for i in range(n-1, -1, -1)] #各レベルの点数を算出しておく(逆順)
howmany = [List[i][0] for i in range(n-1, -1, -1)] #回数も逆順に出しておく

while(ans <= g):
    pre_ans = ans
    ans += max_score[a]
    a += 1
    
for i in range(a):
    res += howmany[i]
    
rest = g - ans
#x = -(-rest // score[a])
if rest > 0:
    x = rest // score[a]

#print(max_score)
#print(score)
#print(howmany)
#print(res)
#print(x)
print(res + x)

Submission status: Runtime Error

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

ans = 0
a = 0
res = 0

max_score = [(i+1)*100*List[i][0]+List[i][1] for i in range(n-1, -1, -1)] #全て答えたときのスコアを算出(逆順)
score = [(i+1)*100 for i in range(n-1, -1, -1)] #各レベルの点数を算出しておく(逆順)
howmany = [List[i][0] for i in range(n-1, -1, -1)]

while(ans + max_score[a] <= g):
    ans += max_score[a]
    a += 1

for i in range(a):
    res += howmany[i]
    
rest = g - ans
x = -(-rest // score[a])
x = rest // score[a]
    
#print(max_score)
#print(score)
#print(howmany)
#print(res)
print(res + x)