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:
P=[]
C=[]
point=1000 
D,G=map(int,input().split())
for i in range(D):
    p,c= map(int,input().split())
    P.append(p)
    C.append(c)

for i in range(2**D) :
    score=0
    solve=0
    needproblem=0
    for j in range(D) :            
        if (i>>j) & 1 :
            score+=P[j]*100*(j+1)+C[j]
            solve+=P[j]
        if (~i>>j) & 1 :                
            needproblem=j+1
            
    if score>G :
        point=min(point,solve)
    elif score<=G :                
        needsolve=(G-score)//(needproblem*100)
        if needsolve>P[needproblem-1] :  
            continue
        elif needsolve<=P[needproblem-1] :
            resolve=solve+needsolve
            point=min(point,resolve)
print(point)

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
P=[]
C=[]
point=1000

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

#とりあえず全部解くor解かないで目標スコアを超えるか超えないかを考える

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

#ぎりぎりスコアが届いていない場合、1問も解かなかった問題の中で最も一題あたりの点が高い問題だけ解いてみる
#中途半端に大問を解ききるのが１種類以下でも目標に届く場合もあるという予想

    elif score<=G :                
        needsolve=(G-score)//(needproblem*100)
        if needsolve>P[needproblem-1] :   
        elif needsolve<=P[needproblem-1] :
            resolve=solve+needsolve
            point=min(point,resolve)

print(point)

Submission status: Runtime Error

Solution code:
P=[]
C=[]
point=1000    #全問題数

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

#とりあえず全部解くor解かないで目標スコアを超えるか超えないかを考える


for i in range(2**D) :
    score=0
    solve=0
    needproblem=0
    for j in range(D) :                  #全正解した大問をスコアに変換
        if (i>>j) & 1 :
            score+=P[j]*100*(j+1)+C[j]
            solve+=P[j]
        if (~i>>j) & 1 :                  #1問も解かなかった問題の中で最も一題あたりの点が高い問題
            needproblem=j+1
    if score>G :
        point=min(point,solve)

#ぎりぎりスコアが届いていない場合、1問も解かなかった問題の中で最も一題あたりの点が高い問題だけ解いてみる
#中途半端に大問を解ききるのが１種類以下でも目標に届く場合もあるという予想

    elif score<=G :                
        needsolve=(G-score)//(needproblem*100)
        if needsolve>P[needproblem-1] :            #1問も解かなかった問題の中で最も一題あたりの点が高い問題を解いても届かないのでやり直し
            continue
        elif needsolve<=P[needproblem-1] :
            resolve=solve+needsolve
            point=min(point,resolve)

print(point)

Submission status: Runtime Error

Solution code:

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

Submission status: Runtime Error

Solution code:
def dfs(i, sum, count, unsolve):
 global ans
 if i == D:
  #G点に満たなければunsolveのうち最も大きいものを解く
  if sum < G:
   use = max(unsolve)
  #解く問題が問題数を超えないようにする
   N = min(pc[use-1][0], -(-(g-sum)//(100*use)))
   count += N 
   sum += N * 100 * use
  if sum > G:
   ans = min(ans, count)
 else:
 dfs(i + 1, sum, count, unsolve)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], unsolve - {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:
from sys import exit
n, m, x = map(int, input().split())

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

ave = [[0, i] for i in range(n)]

for i in range(m):
    p = 0
    for j in range(n):
        p += a[j][i]
        ave[j][0] += a[j][i] / m
    if p < x:
        print(-1)
        exit()

for i in range(n):
    ave[i][0] = c[i] / ave[i][0]
ave.sort()

ans = 0
now = [0] * m
for i in range(n):
    for j in range(m):
        now[j] += a[ave[i][1]][j]
    ans += c[ave[i][1]]
    for j in range(m):
        f = True
        if now[j] < x:
            f = False
            break
    if f:
        print(ans)
        exit()

Submission status: Runtime Error

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

  # print(D, G, P)
  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)

    # print(f'bset:{bset}, num_p:{num_p}')

    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)
        # print(i, list(range(0, maxv, 100*(i+1))))
        # print(f'res:{res} so solve {100*(i+1)} * {num_take}')
        num_p += num_take
        res -= 100*(i+1)*num_take
        if num_p < minp:
          minp = num_p
        break

      res -= maxv
      # print(f'solve {i+1} * {P[i][0]-1}')
      num_p += (P[i][0]-1)

  print(minp)


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

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(-(-(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:
from itertools import product
D, G = map(int, input().split())
P, C = zip(*[map(int, input().split()) for _ in range(D)])
INF = 10**18
ans = INF
for bit in product((0, 1), repeat=D):
    p = list(P)
    cnt = 0
    score = 0
    for i in range(D):
        if bit[i]:
            score += C[i]
            score += P[i]*100*(i+1)
            cnt += P[i]
            p[i] = 0


        if score+sum(p[i]*100*(i+1) for i in range(D)) < G:
        	continue
 
    idx = D-1
    while score < G:
        while not p[idx]:
            idx -= 1
        score += 100*(idx+1)
        p[idx] -= 1
        cnt += 1
    if cnt < ans:
        ans = cnt
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import product
D, G = map(int, input().split())
P, C = zip(*[map(int, input().split()) for _ in range(D)])
INF = 10**18
ans = INF
for bit in product((0, 1), repeat=D):
    p = list(P)
    cnt = 0
    score = 0
    for i in range(D):
        if bit[i]:
            score += C[i]
            score += P[i]*100*(i+1)
            cnt += P[i]
            p[i] = 0


        if score+sum(p[i]*100*(i+1) for i in range(D)) < G:
        continue
 
    idx = D-1
    while score < G:
        while not p[idx]:
            idx -= 1
        score += 100*(idx+1)
        p[idx] -= 1
        cnt += 1
    if cnt < ans:
        ans = cnt
print(ans)

Submission status: Runtime Error

Solution code:
(d, g), *s = [list(map(int, i.split())) for i in open(0)]
s = [[i[0] * -~n * 100 + i[1], i[0]] for n, i in enumerate(s)]
a = 10**9
for b in range(1 << d):
    su = sum(s[i][0] * (b >> i & 1) for i in range(d))
    n = sum(s[i][1] * (b >> i & 1) for i in range(d))
    if su <= g:
        m = d-bin(b)[2:].zfill(d).find("0")
        if m==-1:
            if su==g:
              print(n)
              exit()
            continue
        e =-~(g-su)//(m*100)
        if e < s[m-1][1]:
            a = min(a,n + e)
    if su > g:
        a = min(a,n)
print(a)

Submission status: Runtime Error

Solution code:
(d, g), *s = [list(map(int, i.split())) for i in open(0)]
s = [[i[0] * -~n * 100 + i[1], i[0]] for n, i in enumerate(s)]
a = 10**9
for b in range(1 << d):
    su = sum(s[i][0] * (b >> i & 1) for i in range(d))
    n = sum(s[i][1] * (b >> i & 1) for i in range(d))
    if su <= g:
        m = d-bin(b)[2:].zfill(d).find("0")
        e =-~(g-su)//(m*100)
        if e < s[m-1][1]:
            a = min(a,n + e)
    if su > g:
        a = min(a,n)
print(a)

Submission status: Runtime Error

Solution code:
(d, g), *s = [list(map(int, i.split())) for i in open(0)]
s = [[i[0] * -~n * 100 + i[1], i[0]] for n, i in enumerate(s)]
a = 10**9
for b in range(1 << d):
    su = sum(s[i] * (b >> i & 1) for i in range(d))
    n = sum(s[i][1] * (b >> i & 1) for i in range(d))
    if su <= g:
        m = d-bin(b)[2:].zfill(d).find("0")
        e =-~(g-su)//(m*100)
        if e < s[m-1][1]:
            a = min(a,n + e)
    if su > g:
        a = min(a,n)
print(a)

Submission status: Runtime Error

Solution code:
D,G=map(int,input().split(" "))
ps=[]
for i in range(D):
    ps.append(list(map(int,input().split(" "))))
dp=[]
    
def minq(p,g):
    if g <= 0:
        return 0
    for i in range(len(dp)):
        if p==dp[i][0]:
            return dp[i][1]
    res=10**8
    for i in range(D):
        if p[i][0]==1:
            p[i][0]-=1
            res=min(1+minq(p,g-100*(i+1)-p[i][1]),res)
            p[i][0]+=1
        if p[i][0] >= 2:
            p[i][0]-=1
            res=min(1+minq(p,g-100*(i+1)),res)
            p[i][0]+=1
    dp.append([[p],[res]])
    return res

print(minq(ps,G))

Submission status: Runtime Error

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

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

ans=float('inf')
for bit in range(2**d):
    b = 0
    score = 0
    num = 0
    # ボーナスを貰えるまで問題を解く場合を計算
    # bit探索し、ボーナスを貰うパターンを網羅する
    for i in range(d):
        if (bit >> i) & 1:
            # 問題を解いた点 + ボーナス
            score += pc[0][i] * (i+1) * 100 + pc[1][i]
            # 解いた問題数
            num += pc[0][i]
        else:
            # ボーナスを貰えるまで解かない問題の場合
            # この値には最終的にはボーナスを貰えるまでは解かない、最大点がもらえる問題の番号が入る
            b = i

    # ボーナスを貰えるまでは解かない問題による加点と回答の更新を行う
    for j in range(pc[b][0]):
        if score>=g and num<ans:
            ans=num
        score+=(b+1)*100
        num+=1

print(ans)

Submission status: Runtime Error

Solution code:
D,G = map(int, input().split())
INF = 10**10
# 各点数を得るときの、最小の問題数
n = 3*10**4
dp = [INF] * n
dp[0] = 0
for i in range(1,D+1):
    p,c = map(int, input().split())
    c //= 100
    tmp = dp[:]
    for j in range(G//100+1):
        if tmp[j] == INF: continue
        for k in range(1,p+1):
            dp[j+i*k] = min(tmp[j]+k, dp[j+i*k])
        dp[j+i*p+c] = min(tmp[j]+p, dp[j+i*p+c])

ans = INF
for score in dp[G//100:]:
    if score == INF: continue
    ans = min(score, ans)
print(ans)

Submission status: Runtime Error

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

l=[]
for i in range(d):
    l.append(list(map(int,input().split())))
print(l)
def dfs(i,f,j,a):#i:100*i f:合計 j:iのj個目 :解いた数
    if f>=g or i>d:
        return a
    else:
        if j==l[i-1][0]:
            j=0
            if dfs(i+1,f,j+1,a):
                return True
            if dfs(i+1,f+100*i,j+1,a+1):
                return True
        else:
            if dfs(i,f,j+1,a):
                return True
            if dfs(i,f+100*i,j+1,a+1):
                return True
    return False
if dfs(1,0,0,0):
    print(dfs(1,0,0,0))
else:
    print("No")

Submission status: Runtime Error

Solution code:
import sys 
sys.setrecursionlimit(10**6)

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

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

  else:
    dfs(i+1,sum,count,nokori)
    dfs(i+1,sum+pc[i][0]*100*(i+1)+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:
import itertools
import math

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

for i in range(d):
  for j in itertools.combinations(range(d),i):
    score,pro1=0,0
    for k in j:
      score += (PC[k][1] + (k+1) * 100 * PC[k][0])
      pro1 += PC[k][0]
    for k in range(d):
      pro2 = pro1
      if score >= g:
        ans.append(pro2)
      elif k in j:
        continue
      p=math.ceil((g-score) / ((k+1) * 100))
      if 0 < p < PC[k][0]:
        pro2 += p
        ans.append(pro2)
        
print(min(ans))

Submission status: Runtime Error

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

#print(pc)
minn=10000
flug=[]
def func(D,G,pc,flug,i=0,summ=0,num=0):
    global minn
    if i==D:
        #print(flug,summ,num)
        if summ>=G:
            minn=min(minn,num)
            return 0
        else:
            for j,bit in enumerate(reversed(flug)):
                if bit==0:
                    for k in range(pc[D-1-j][0]):
                        summ+=(D-j)*100
                        if summ>=G:
                            num+=(k+1)
                            minn=min(minn,num)
        return 0

    return func(D,G,pc,flug+[1],i+1,summ+pc[i][0]*100*(i+1)+pc[i][1],num+pc[i][0]) + func(D,G,pc,flug+[0],i+1,summ,num)


func(D,G,pc,flug)
print(minn)

Submission status: Runtime Error

Solution code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    INF = 10**5
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    D,G = LI()
    pc = [LI() for _ in range(D)]
    ans = INF
    for p in itertools.permutations([0,1,2,3,4,5,6,7,8,9]):
        g = G
        cnt = 0
        for i in p:
            if g < pc[i][0] * (i+1) * 100:
                cnt += math.ceil(g/((i+1)*100))
                break
            else:
                cnt += pc[i][0]
                g -= pc[i][0] * (i+1) * 100 + pc[i][1]
            if g <= 0: break
        ans = min(ans,cnt)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    d, g = MI()
    data = np.array(sys.stdin.buffer.read().split(), np.int64)
    data = data.reshape(-1, 2)
    p = data[:, 0]
    c = data[:, 1]

    problems = np.zeros(2 ** d, np.int64)
    points = np.zeros(2 ** d, np.int64)
    for i in range(d):
        problems[1 << i : 1 << (i + 1)] = problems[: 1 << i] + p[i]
        points[1 << i : 1 << (i + 1)] = points[: 1 << i] + c[i] + 100 * (i + 1) * p[i]

    for i in range(2 ** d):
        while points[i] < g:
            for j in reversed(range(d)):
                if (i >> j) & 1:
                    continue
                for _ in range(p[j]):
                    if points[i] >= g:
                        break
                    points[i] += 100 * (j + 1)
                    problems[i] += 1

    print(problems.min())


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#https://atcoder.jp/contests/abc104/tasks/abc104_c

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

for i in range(d):
  pc.append(list(map(int,input().split())))

ans = float("inf")

#各配点について解くか解かないかを決め、その上で G 点に満たなければ、まだ解いてない配点のうち一番高い配点のものを足りない分解く

for i in range(2**d):
    count = 0 #解く問題数
    sum = 0
    nokori = set(range(1, d + 1)) #点数の列

    for j in range(d):
        if (i>>j)&1:
            sum += pc[j][0] * (j + 1) * 100 + pc[j][1] #(j+1)*100点+bounus
            count += pc[j][0]
            nokori.discard(j + 1) #(j+1)*100点を処理したので削除

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

print(ans)

Submission status: Runtime Error

Solution code:
def main():
    from itertools import combinations_with_replacement
    from fractions import ceil
    d, g, *pc = map(int, open(0).read().split())
    p, c = pc[::2], pc[1::2]
    ans = 0
    l = range(d)
    for x in combinations_with_replacement(l, d):
        y = list(set(x))
        tmp = g
        count = 0
        for i in y:
            tmp -= (i + 1) * 100 * p[i] + c[i]
            count += p[i]
        if tmp >= g:
            ans = min(ans, count)
        else:
            j = max(y)
            if j == d - 1:
                j -= 1
            else:
                j += 1
            k = ceil(tmp / (100 * (j + 1)))
            if k < p[j]:
                count += k
                ans = min(ans, count)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    from itertools import combinations_with_replacement
    from math import ceil
    d, g, *pc = map(int, open(0).read().split())
    p, c = pc[::2], pc[1::2]
    ans = 0
    l = range(d)
    for x in combinations_with_replacement(l, d):
        y = list(set(x))
        tmp = g
        count = 0
        for i in y:
            tmp -= (i + 1) * 100 * p[i] + c[i]
            count += p[i]
        if tmp >= g:
            ans = min(ans, count)
        else:
            j = max(y)
            if j == d - 1:
                j -= 1
            else:
                j += 1
            k = ceil(tmp / (100 * (j + 1)))
            if k < p[j]:
                count += k
                ans = min(ans, count)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import itertools
from pprint import pprint
import sys 
sys.setrecursionlimit(1000000000)
#基本的に10*100*len(bonus_masterlist)回ループを回せばよい
#len(bonus_masterlist)は最大で2**10=1024
#余裕をもってさらに100倍

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(target):
    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)
        return
    elif plist[target] == count_list[target]:
        bonus_list[target] = 1
        dfs(target-1)
    elif plist[target] > count_list[target]:
        count_list[target] += 1
        dfs(target)

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
import sys 
sys.setrecursionlimit(1000000000)
#基本的に10*100*len(bonus_masterlist)回ループを回せばよい
#len(bonus_masterlist)は最大で2**10=1024
#余裕をもってさらに100倍

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(target):
    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[target] == count_list[target]:
        bonus_list[target] = 1
        dfs(target-1)
    elif plist[target] > count_list[target]:
        count_list[target] += 1
        dfs(target)
    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
import sys 
sys.setrecursionlimit(1000000000)
#基本的に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)]
    i = d-1
    while True:
        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)
            break
        elif plist[i] == count_list[i]:
            bonus_list[i] = 1
            i -= 1
            continue
        elif plist[i] > count_list[i]:
            count_list[i] += 1
            continue


print(mincount)

Submission status: Runtime Error

Solution code:
import itertools
from pprint import pprint
import sys 
sys.setrecursionlimit(1000000000)
#基本的に10*100*len(bonus_masterlist)回ループを回せばよい
#len(bonus_masterlist)は最大で2**10=1024
#余裕をもってさらに100倍

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
import sys 
sys.setrecursionlimit(10*100*1024*100)
#基本的に10*100*len(bonus_masterlist)回ループを回せばよい
#len(bonus_masterlist)は最大で2**10=1024
#余裕をもってさらに100倍

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