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: Time Limit Exceeded

Solution code:
import itertools

d,g = map(int,input().split())
    
arr = []
    
for i in range(d):
    arr.append(list(map(int,input().split())))
    
ans = 10**10

for i in itertools.product((0,1),repeat=d**2):
    score=0
    num=0
    index=0
    
    for j in range(d):
        if i[j]==1:
            score += (j+1)*100*arr[j][0] + arr[j][1]
            num +=arr[j][0]
        else:
            index = max(j,index)
    
    if g - score <=0:
        ans = min(ans,num)
    
    elif g - score <= (index+1) *100*(arr[index][0]-1):
        num+= -(-(g-score)//(100*(index+1)))
        ans =min(ans,num)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


D, G = list(map(int, sys.stdin.buffer.readline().split()))
P, C = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(D)]))
P = np.array(P, dtype=int)
C = np.array(C, dtype=int)

scores = P * np.arange(1, D + 1, dtype=int) * 100 + C
ans = INF
for order in itertools.permutations(range(D)):
    ps = scores[list(order)].cumsum()
    counts = P[list(order)].cumsum()
    i = np.searchsorted(ps, G)
    if i == 0:
        a = math.ceil(G / (order[0] * 100 + 100))
        ans = min(ans, a, P[order[0]])
    else:
        a = counts[i - 1]
        score = ps[i - 1]
        a += min(math.ceil((G - score) / (order[i] *100 + 100)), P[order[i]])
        ans = min(ans, a)
    # print(order, ans)
print(ans)

Submission status: Time Limit Exceeded

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

l = []
for i in range(D):
    P,C = map(int, input().split())
    l.append([])
    sum = 1
    for p in range(P+1):
        sum = (100*(i+1))*p
        if p==(P):
            sum = sum + C
        l[i].append(sum)

ans_min = float("inf")

def dfs(index, count, ans):
    global min
    global ans_min

    if index==(D):
        if ans_min > ans and count>=G:
            ans_min = ans
        return

    for p in range(len(l[index])):
        dfs(index+1, count+l[index][p], ans+p)

    return
    
dfs(0, 0, 0)
print(ans_min)

Submission status: Time Limit Exceeded

Solution code:
#gが目標点数
d,g=map(int,input().split())

cnt=10*1000+1
numberOfMondai=0
KindOfMondai = {}
kindOfMondaiBin=""
zero=""

for i in range(1,d+1):
    c,p=map(int,input().split())
    if c>1:
        for j in range(c):
            KindOfMondai[zero+"0"*(c-j-1)+"1"+"0"*(j)]=i*100
    else:
        KindOfMondai[zero+"1"]=i*100
    kindOfMondaiBin=zero+"1"*c
    zero=zero+"0"*c
    KindOfMondai[kindOfMondaiBin]=p
    numberOfMondai+=c

KindOfMondaiZero={}
for key in KindOfMondai.keys():
    KindOfMondaiZero[int(key+"0"*(numberOfMondai-len(key)),2)]=KindOfMondai[key]

#print(KindOfMondaiZero)

number=10**9
for i in range(2**numberOfMondai):
    point=0

    for key in KindOfMondaiZero.keys():
        if (key&i)==key:
            point+=KindOfMondaiZero[key]
    #print(bin(i),point)

    if point>=g:
        number=min(number,bin(i).count("1"))

print(number)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

d,g = LI()
pc = [LI() for _ in range(d)]
ans = inf
for i in permutations(range(d)):
    cnt = 0
    tmp = 0
    for j in list(i):
        p,c = pc[j]
        flg = (g-tmp) % (100*(j+1))
        t = min(p,(g - tmp)//(100*(j+1)))
        tmp += 100*(j+1)*t
        if t == p:
            tmp += c
            cnt += t
            if tmp >= g:
                break
        else:
            cnt += t + (flg != 0)
            break
    ans = min(ans,cnt)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

d,g = LI()
pc = [LI() for _ in range(d)]
ans = inf
for i in permutations(range(d)):
    cnt = 0
    tmp = 0
    for j in list(i):
        flg = (g-tmp) % (100*(j+1))
        t = min(pc[j][0],(g - tmp)//(100*(j+1)))
        tmp += 100*(j+1)*t
        if t == pc[j][0]:
            tmp += pc[j][1]
            cnt += t
            if tmp >= g:
                break
        else:
            cnt += t + (flg != 0)
            break
    ans = min(ans,cnt)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
D, G = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(D)]
plst = [0] * D
ans = 0
for i in range(D):
    ans += p[i][0]

def dfs(n):
    global ans
    if n == D:
        cnt = 0
        total = 0
        for i in range(D):
            if plst[i] == 0:
                continue
            elif plst[i] == 1:
                cnt += p[i][0]
                total += (100 * (i + 1) * p[i][0]) + p[i][1]
        for j in range(D):
            if plst[j] == 2:
                for k in range(p[j][0] - 1):
                    total += (100 * (j + 1))
                    cnt += 1
                    if total >= G:
                        break
        if total >= G:
            ans = min(ans, cnt)
        return

    for i in range(3):
        plst[n] = i
        dfs(n + 1)
    return

dfs(0)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
D, G = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(D)]
plst = [0] * D
ans = 0
for i in range(D):
    ans += p[i][0]

def dfs(n):
    global ans
    if n == D:
        cnt = 0
        total = 0
        for i in range(D):
            if plst[i] == 0:
                continue
            elif plst[i] == 1:
                cnt += p[i][0]
                total += (100 * (i + 1) * p[i][0]) + p[i][1]
        for j in range(D):
            if plst[j] == 2:
                for k in range(p[j][0] - 1):
                    total += (100 * (j + 1))
                    cnt += 1
                    if total >= G:
                        ans = min(ans, cnt)
        if total >= G:
            ans = min(ans, cnt)
        return

    for i in range(3):
        plst[n] = i
        dfs(n + 1)
    return

dfs(0)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
d, g = map(int, input().split())
q = []
bonus = []
ans = []
for n in range(1,d+1):
  p, c =  map(int, input().split())

  for a in range(1,p+1):
    q.append( 100 * n)

  bonus.append(c)

totalQ = len(q)

for i in range(2 ** totalQ):
  clear = []
  total = 0

  for j in range(totalQ):

    if((i >> j) & 1):
      clear.append(q[j])
      total += q[j]

  for b in range(1,d+1):

    if(clear.count(100 * b) == q.count(100 * b)):
      if(g - bonus[b-1] <= total ):
        ans.append(len(clear))
    else:
      if(g <= total):
        ans.append(len(clear))
print(min(ans))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    d, g = map(int, args[0].split())
    g //= 100
    pc = [tuple(map(int, a.split())) for a in args[1:]]
    inf = 10**12
    dp = {}

    for i, (p, c) in enumerate(pc):
        c //= 100
        if i == 0:
            for k in range(p):
                s = min(g, (i+1)*(k+1) + (c if k+1 == p else 0))
                dp[s] = k+1
        else:
            items = tuple(dp.items())
            for t, m in items:
                for k in range(p):
                    s = min(g, (i+1)*(k+1) + (c if k+1 == p else 0))
                    s_t = min(g, s+t)
                    dp[s] = min(dp.get(s, inf), k+1)
                    dp[s_t] = min(dp.get(s_t, inf), k+1+m)
    return str(dp[g])


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Time Limit Exceeded

Solution code:
d,g=map(int,input().split())
g=g//100
pc=[list(map(int,input().split())) for i in range(d)]
P=0
C=0#合計
for i in range(d):
    pc[i][1]=pc[i][1]//100
    C=(C+pc[i][1]+pc[i][0]*(i+1))
    P+=pc[i][0]
dp=[10000000]*(C+1)
for i in range(d):
    dp_sub=[10000000]*(C+1)
    for j in range(C+1):
        if j==0:
            for k in range(1,pc[i][0]+1):
                if k!=pc[i][0]:
                    dp_sub[k*(i+1)]=k
                else:
                    dp_sub[k*(i+1)+pc[i][1]]=k
        elif dp[j]!=10000000:
            for k in range(1,pc[i][0]+1):
                if k!=pc[i][0]:
                    dp_sub[j+k*(i+1)]=min(dp[j]+k,dp_sub[j+k*(i+1)])
                else:
                    dp_sub[j+k*(i+1)+pc[i][1]]=min(dp[j]+k,dp_sub[j+k*(i+1)+pc[i][1]])

    for j in range(C+1):
        if dp_sub[j]!=0:
            dp[j]=min(dp[j],dp_sub[j])
m=P
for i in range(g,C+1):
    if dp[i]!=0:
        m=min(m,dp[i])
print(m)

Submission status: Time Limit Exceeded

Solution code:
d,g=map(int,input().split())
g=g//100
pc=[list(map(int,input().split())) for i in range(d)]
P=0
C=0#合計
for i in range(d):
    pc[i][1]=pc[i][1]//100
    C=(C+pc[i][1]+pc[i][0]*(i+1))
    P+=pc[i][0]
dp=[0]*(C+1)
#print(C)
for i in range(d):
    dp_sub=[0]*(C+1)
    for j in range(C+1):
        if j==0:
            for k in range(1,pc[i][0]+1):
                if k!=pc[i][0]:
                    dp_sub[k*(i+1)]=k
                else:
                    dp_sub[k*(i+1)+pc[i][1]]=k
        elif dp[j]!=0:
            for k in range(1,pc[i][0]+1):
                if k!=pc[i][0]:
                    if dp_sub[j+k*(i+1)]!=0:
                        dp_sub[j+k*(i+1)]=min(dp[j]+k,dp_sub[j+k*(i+1)])
                    else:
                        dp_sub[j+k*(i+1)]=dp[j]+k
                else:
                    #print(j+k*(i+1)+pc[i][1])
                    if dp_sub[j+k*(i+1)+pc[i][1]]!=0:
                        dp_sub[j+k*(i+1)+pc[i][1]]=min(dp[j]+k,dp_sub[j+k*(i+1)+pc[i][1]])
                    else:
                        dp_sub[j+k*(i+1)+pc[i][1]]=dp[j]+k
    #print(dp_sub)
    for j in range(C+1):
        if dp_sub[j]!=0:
            if dp[j]==0:
                dp[j]=dp_sub[j]
            else:
                dp[j]=min(dp[j],dp_sub[j])
m=P
for i in range(g,C+1):
    if dp[i]!=0:
        m=min(m,dp[i])
print(m)
#print(dp)

Submission status: Time Limit Exceeded

Solution code:
d, g = map(int, input().split())
pc = []
for _ in range(d):
    _p, _c = map(int, input().split())
    pc.append([_p, _c])
p = sum([i[0] for i in pc])
score = []
for i in range(len(pc)):
    for j in range(pc[i][0]):
        score.append((i+1)*100)
answer = 10000
for i in range(2 ** p):
    tmp = []
    ans = 0
    for j in range(p):
        if ((i >> j) & 1):
            tmp.append(j)
    for j in tmp:
        ans += score[j]
    for j in range(len(pc)):
        if j == 0:
            l = [_ for _ in tmp if 0 <= _ < pc[0][0]]
            if len(l) == pc[0][0]:
                ans += pc[0][1]
        elif j == len(pc)-1:
            s = score.index((j+1)*100)
            l = [_ for _ in tmp if s <= _]
            if len(l) == pc[-1][0]:
                ans += pc[-1][1]
        else:
            s = score.index((j+1)*100)
            e = score.index((j+1)*100) - 1
            l = [_ for _ in tmp if s <= _ <= e]
            if len(l) == pc[j][0]:
                ans += pc[j][1]
    if ans >= g:
        if answer > len(tmp):
            answer = len(tmp)
print(answer)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7
ans = count = 0; pro = 1

d,g=map(int,input().split());g//=100
D=collections.defaultdict(lambda: inf )
D[0]=0
for i in range(1,d+1):
    p,c=map(int,input().split());c//=100
    # for key, value in tuple(D.items()):
    #     print(D[key],p)
    #     D[key+i*p+c//100] = min(D[key+i*p+c//100], D[key]+p)
    S=D.copy()
    for key,value in S.items():
        for k in range(1,p):    
        # print(D[key+i])
            D[key+i*k] = min(D[key+i*k],S[key]+k)
        D[key+i*p+c] = min(D[key+i*p+c],S[key]+p)
ans=inf
for key,value in D.items():
    # print(key,value)
    if key>=g:
        ans=min(ans,value)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7
ans = count = 0; pro = 1

d,g=map(int,input().split());g//=100
D=collections.defaultdict(lambda: inf )
D[0]=0
for i in range(1,d+1):
    p,c=map(int,input().split());c//=100
    # for key, value in tuple(D.items()):
    #     print(D[key],p)
    #     D[key+i*p+c//100] = min(D[key+i*p+c//100], D[key]+p)
    S=D.copy()
    for key,value in tuple(D.items()):
        for k in range(1,p):    
        # print(D[key+i])
            D[key+i*k] = min(D[key+i*k],S[key]+k)
        D[key+i*p+c] = min(D[key+i*p+c],S[key]+p)
ans=inf
for key,value in sorted(D.items()):
    # print(key,value)
    if key>=g:
        ans=min(ans,value)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import copy
d, g = map(int, input().split())
p = [0] * d
c = [0] * d
for i in range(d):
    p[i], c[i] = map(int, input().split())

#はじめどこから足すか決めてない
def SumScore(i, s, counter, l):
    global ans #ここが大切
    if counter[-1] != 0: #これはエラー処理で無視させる
        pass
    
    elif s >= g: #必ず総合スコアはg点以上になるから，これが停止条件
        if counter[-1] == 0:
            z = sum(counter[: d])
            ans = min(ans, z)
            return ans

    else:
        if d <= i: #indexの問題発生
            counter[-1] += 1
            return SumScore(i, s, counter, l)
        elif counter[i] == p[i]: #コンプリートボーナスを得る時，counterが限界に
            return SumScore(i + 1, s + c[i], counter, l)
        else: #コンプリートボーナスを得ない時
            #リストはこうやってコピーしないと変更を更新してしまう
            cp_counter = copy.copy(counter) #ここ初歩的だけどまじで困った
            x = SumScore(i + 1, s, cp_counter, l) #次に進む
            counter[i] += 1
            y = SumScore(i, s + (i + 1) * 100, counter, l) #素直に足す
            return x, y
    

ans = float("inf")
SumScore(0, 0, [0] * (d + 1), l = [])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import defaultdict
input = sys.stdin.readline

D, G = [int(x) for x in input().strip().split()]
P = [''] * D
for d in range(D):
    p, c = [int(x) for x in input().strip().split()]
    P[d] = [0] + [(d + 1) * 100 * (i + 1) for i in range(p)]
    P[d][-1] += c

d = defaultdict(int)
def f(P, D, qnum, trial, d, score=[]):
    if (qnum, trial, sum(score)) in d:
        return d[(qnum, trial, sum(score))]
    #print('x={}, a={}, c={}'.format(x, a, c))
    if qnum == D:
        if sum(score) >= G:
            #print('  OK : {}'.format(a))
            return trial
        else:
            #print('  NG')
            return 10 ** 9 + 7
    ret = 10 ** 9 + 7
    for n in range(len(P[qnum])):
        t = score[:]
        t.append(P[qnum][n])
        ret = min(ret, f(P, D, qnum+1, trial+n, d, t))
    d[(qnum, trial, sum(score))] = ret
    return ret

print(f(P, D, 0, 0, d))

Submission status: Time Limit Exceeded

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

D, G = [int(x) for x in input().strip().split()]
P = [''] * D
for d in range(D):
    p, c = [int(x) for x in input().strip().split()]
    P[d] = [0] + [(d + 1) * 100 * (i + 1) for i in range(p)]
    P[d][-1] += c

def f(P, x, D, a, c=[]):
    if x == D:
        if sum(c) >= G:
            return a
        else:
            return 10 ** 9 + 7
    ret = 10 ** 9 + 7
    for n in range(len(P[x])):
        t = c[:]
        t.append(P[x][n])
        ret = min(ret, f(P, x+1, D, a+n,t))
    return ret

print(f(P, 0, D, 0))

Submission status: Time Limit Exceeded

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)

res = 0
count = 0
ans_list = []

def dfs(i, p, c, res, count):
    if i == 0:
        if res >= g:
            ans_list.append(count)
    else:
        for j in range(p[i - 1] + 1):
            _count = count + j
            _res = res + 100 * j * i
            if j == p[i - 1]:
                _res += c[i - 1]
            dfs(i - 1, p, c, _res, _count)

dfs(d, p, c, res, count)
print(min(ans_list))

Submission status: Time Limit Exceeded

Solution code:
from math import ceil


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


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


def solve(goal, count, meta):
    if (goal <= 0):
        return count

    min_count = 999999999

    for m in meta:
        meta2 = list(meta)
        meta2.remove(m)
        c = solve(goal - m[3], count + m[0], meta2)
        if c < min_count:
            min_count = c

    for m in reversed(meta):
        if goal - m[0] * m[1] > 0:
            continue
        c = count + ceil(goal / m[1])
        if c < min_count:
            min_count = c
        break

    return min_count


def main():
    d, goal = tuple(input_ints())

    meta = list()
    for i in range(d):
        problems, bonus = tuple(input_ints())
        score = (i + 1) * 100
        meta.append((problems, score, bonus, score * problems + bonus))

    count = solve(goal, 0, meta)
    print(count)


main()

Submission status: Time Limit Exceeded

Solution code:
from math import ceil


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


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


def solve(goal, count, meta):
    if (goal <= 0):
        return count

    min_count = 999999999

    for m in meta:
        meta2 = list(meta)
        meta2.remove(m)
        c = solve(goal - m[3], count + m[0], meta2)
        if c < min_count:
            min_count = c

    for m in meta:
        if goal - m[0] * m[1] > 0:
            continue
        c = count + ceil(goal / m[1])
        if c < min_count:
            min_count = c
        break

    return min_count


def main():
    d, goal = tuple(input_ints())

    meta = list()
    for i in range(d):
        problems, bonus = tuple(input_ints())
        score = (i + 1) * 100
        meta.append((problems, score, bonus, score * problems + bonus))

    count = solve(goal, 0, meta)
    print(count)


main()

Submission status: Time Limit Exceeded

Solution code:
from math import ceil


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


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


def solve(goal, count, meta):
    if (goal <= 0):
        return count

    min_count = 999999999

    for m in meta:
        meta2 = list(meta)
        meta2.remove(m)
        c = solve(goal - m[3], count + m[0], meta2)
        if c < min_count:
            min_count = c

    for m in meta:
        if goal - m[0] * m[1] > 0:
            continue
        c = count + ceil(goal / m[1])
        if c < min_count:
            min_count = c

    return min_count


def main():
    d, goal = tuple(input_ints())

    meta = list()
    for i in range(d):
        problems, bonus = tuple(input_ints())
        score = (i + 1) * 100
        meta.append((problems, score, bonus, score * problems + bonus))

    count = solve(goal, 0, meta)
    print(count)


main()

Submission status: Time Limit Exceeded

Solution code:
### ABC104C - All Green
from itertools import permutations


def main():
    D, G = map(int, input().split())
    A = [(0, 0)] + [tuple(map(int, input().split())) for _ in range(D)]
    ans = float("inf")
    for perm in permutations(range(1, D + 1), D):
        cur, cnt = G, 0
        for i in perm:
            point, (num, bonus) = i * 100, A[i]
            if cur / point < num:
                cnt += cur // point
                cur -= point * (cur // point)
            else:
                cnt += num
                cur -= point * num + bonus
            if cur <= 0:
                ans = min(ans, cnt)
                break
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
D, G = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(D)]
visited = [0] * D
def dfs(s, c):
  temp = 10 ** 3
  for i in range(D):
    if visited[i] == 0:
      visited[i] = 1
      if s >= p[i][0] * (i + 1) * 100 + p[i][1]:
        temp = min(temp, dfs(s - p[i][0] * (i + 1) * 100 - p[i][1], c + p[i][0]))
      else:
        temp = min(temp, -(-s // ((i + 1) * 100)) + c, p[i][0] + c)
      visited[i] = 0
  return temp
print(dfs(G, 0))

Submission status: Time Limit Exceeded

Solution code:
#ABC 104 C - All Green
#順列総当たりでやる

import itertools

d, g = map(int, input().split())
#print(d)
p=[]
c=[]
ld = []
for i in range(d):
  pk, ck = map(int, input().split())
  p.append(pk)
  c.append(ck)
  ld.append(i)

jun = list(itertools.permutations(ld))
ans=10000

for j in jun:
  #順列の数だけ試す。j[番号]で調べてる順列の番号番目の数を返す
  ten = 0
  mondaisu = 0
  for k in range(d):
    bango = j[k]
    katen = (bango + 1)*100*p[bango] + c[bango]
#    print("n問目"+str(bango +1) + "加点"+ str(katen))
    if ten + katen > g:
      nokori = ((g-ten)-1)//((bango + 1)*100) + 1
      if nokori > p[bango]:#ボーナス点がないと届かない場合
        mondaisu += p[bango]
      else:
        mondaisu += nokori
      break
    else:
      ten += katen
      mondaisu += p[bango]
  if ans > mondaisu:
    ans = mondaisu
#  print(str(j) + "問題数" + str(mondaisu) +"答えリスト")
#  print(ans_list)
        
print(ans)      
  
#print(jun[0][1])

  
#print(p)
#print(c)

Submission status: Time Limit Exceeded

Solution code:
#ABC 104 C - All Green
#順列総当たりでやる

import itertools

d, g = map(int, input().split())
#print(d)
p=[]
c=[]
ld = []
for i in range(d):
  pk, ck = map(int, input().split())
  p.append(pk)
  c.append(ck)
  ld.append(i)

jun = list(itertools.permutations(ld))
ans_list=[]

for j in jun:
  #順列の数だけ試す。j[番号]で調べてる順列の番号番目の数を返す
  ten = 0
  mondaisu = 0
  for k in range(d):
    bango = j[k]
    katen = (bango + 1)*100*p[bango] + c[bango]
#    print("n問目"+str(bango +1) + "加点"+ str(katen))
    if ten + katen > g:
      nokori = ((g-ten)-1)//((bango + 1)*100) + 1
      if nokori > p[bango]:#ボーナス点がないと届かない場合
        mondaisu += p[bango]
      else:
        mondaisu += nokori
      break
    else:
      ten += katen
      mondaisu += p[bango]
  ans_list.append(mondaisu)
#  print(str(j) + "問題数" + str(mondaisu) +"答えリスト")
#  print(ans_list)
        
print(min(ans_list))      
  
#print(jun[0][1])

  
#print(p)
#print(c)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math

d, g = map(int, input().split())
ls = [[100 * (i + 1)] + list(map(int, input().split())) for i in range(d)]
s0 = [a * p for a, p, _ in ls]
s1 = [a * p + c for a, p, c in ls]

res = float('inf')
for indices in itertools.permutations(range(d)):
    count = 0
    s = 0
    for i in indices:
        if s + s0[i] >= g:
            count += math.ceil((g - s) / (100 * (i + 1)))
            break
        else:
            count += ls[i][1]
            if count >= res:
                break
            s += s1[i]
            if s >= g:
                break
    res = min(res, count)
print(res)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math

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

res = float('inf')
for indices in itertools.permutations(range(d)):
    count = 0
    s = 0
    for i in indices:
        p, c = ls[i]
        if s + 100 * (i + 1) * p >= g:
            count += math.ceil((g - s) / (100 * (i + 1)))
            break
        else:
            count += p
            if count >= res:
                break
            s += 100 * (i + 1) * p + c
            if s >= g:
                break
    res = min(res, count)
print(res)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math

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

res = float('inf')
for indices in itertools.permutations(range(d)):
    count = 0
    s = 0
    for i in indices:
        p, c = ls[i]
        if s + 100 * (i + 1) * p >= g:
            count += math.ceil((g - s) / (100 * (i + 1)))
            break
        else:
            count += p
            s += 100 * (i + 1) * p + c
            if s >= g:
                break
    res = min(res, count)
print(res)

Submission status: Time Limit Exceeded

Solution code:
d, g = map(int, input().split())
p = [0] * (d+1)
c = [0] * (d+1)
maximum = 10 * 100 + 1

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

global min_count
min_count = maximum
def dfs(i, score, count):
    global min_count
    if i > d:
        if score >= g:
            return count
        else:
            return maximum
    elif score >= g:
        if count < min_count:
            min_count = count
        return count
    elif min_count < count:
        return maximum
    else:
        ans = []
        for j in range(0, p[i]+1):
            next_score = score + 100 * i * j
            if j == p[i]:
                next_score += c[i]
            ans.append(dfs(i+1, next_score, count+j))
        return min(ans)

print(dfs(1, 0, 0))

Submission status: Time Limit Exceeded

Solution code:
d, g = map(int, input().split())
p = [0] * (d+1)
c = [0] * (d+1)
maximum = 10 * 100 + 1

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

def dfs(i, score, count):
    if i > d:
        if score >= g:
            return count
        else:
            return maximum
    elif score >= g:
        return count
    else:
        ans = []
        for j in range(0, p[i]+1):
            next_score = score + 100 * i * j
            if j == p[i]:
                next_score += c[i]
            ans.append(dfs(i+1, next_score, count+j))
        return min(ans)

print(dfs(1, 0, 0))

Submission status: Time Limit Exceeded

Solution code:
import itertools
D, G = map(int, input().split())
score_list = []
for i in range(D):
    p, c = map(int, input().split())
    score_list.append([(i + 1) * 100] * (p - 1) + [c + (i + 1) * 100])
full_score = [sum(i) for i in score_list]
per = list(itertools.permutations(range(D)))
ans = 10000

for k in per:
    pro = 0
    sco = 0
    for i in k:
        if G >= sco + full_score[i]:
            sco += full_score[i]
            pro += len(score_list[i])
        else:
            for j in score_list[i]:
                sco += j
                pro += 1
                if sco >= G:
                    break
                else:
                    continue
        if sco >= G:
            break
        else:
            continue
    if ans > pro:
        ans = pro
    else:
        continue
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import copy
MAX_DEPTH  = 1000000000000
give_up = MAX_DEPTH
def solve(rest, score, depth, i):
    global give_up
    if give_up <= depth:
        return 
    score += 100 * (i + 1)
    rest[i] -= 1
    depth += 1
    if rest[i] == 0:
        score += c[i]
    if G <= score:
        return depth
    else:
        all_depth = [MAX_DEPTH]
        min_ans = MAX_DEPTH
        for j in range(0, D):
            if rest[i] != 0:
                ans = solve(copy.deepcopy(rest), score, depth, j)
                if ans and ans <= min_ans:
                    min_ans = ans
                if ans and ans <= give_up:
                    give_up = ans
        return min_ans
 
D,G = [int(x) for x in input().split()]
c = []
rest = []
for _ in range(D):
    _p, _c = [int(x) for x in input().split(" ")]
    rest.append(_p)
    c.append(_c)
results = []
for h in range(D):
  results.append(solve(copy.deepcopy(rest), 0, 0, h))
print(min(results))