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:
#3
d,g = map(int,input().split())
lista = []
for i in range(d):
    lista.append([])
    p,c = map(int,input().split())
    lista[i] = [p,c]
    
def search(allcomp,notouch,touch,rem,toachiev,ps):
    #allcomp 全部解く
    #notouch 触らない
    #touch 触る
    #残りの選択肢
    #達成までに必要な得点
    #ここまで解いてる問題数
    if touch != []:
        #print(allcomp,notouch,touch,rem,toachiev,ps)
        point = (touch[0] + 1)*100
        problems = lista[touch[0]][0]
        vnus =  lista[touch[0]][1]
        #print(point,problems,vnus)
        if toachiev == 0:
            return ps
        else:
            needproblems = toachiev//point
            if toachiev%point != 0:
                needproblems += 1
                
            if needproblems<=problems:
                return ps+needproblems
            else:
                if point*problems + vnus >= toachiev:
                    return ps+problems
                else:
                    return 10**9
                
    else:
        if len(rem)==1:
            if toachiev == 0:
                return ps
            else:
                rempoint = (rem[0] + 1)*100
                notouchpoint_max = 0
                if notouch != []:
                    notouchpoint_max = (max(notouch) + 1)*100

                if notouchpoint_max <= rempoint:
                    return search(allcomp,notouch,rem,[],toachiev,ps)
                else:
                    return 10**9
        else:
            if toachiev == 0:
                return ps
            else:
                minp = 10**9
                for i in range(len(rem)):
                    allcomp_t,notouch_t,rem_t,toachiev_t,ps_t = list(allcomp),list(notouch),list(rem),toachiev,ps
                    allcomp_t.append(rem[i])
                    rem_t = rem[:i]+rem[i+1:]
                    toachiev_t = toachiev_t - (rem[i] + 1)*100*lista[rem[i]][0] - lista[rem[i]][1]
                    if toachiev_t <0:
                        toachiev_t = 0
                    ps_t = ps_t + lista[rem[i]][0]
                    case1 = search(allcomp_t,notouch_t,[],rem_t,toachiev_t,ps_t)

                    allcomp_t,notouch_t,rem_t,toachiev_t,ps_t = list(allcomp),list(notouch),list(rem),toachiev,ps
                    notouch_t.append(rem[i])
                    rem_t = rem[:i]+rem[i+1:]
                    case2 = search(allcomp_t,notouch_t,[],rem_t,toachiev_t,ps_t)
                    #print(case1,case2)
                    if minp > min(case1,case2):
                        minp = min(case1,case2)
                    
            return minp
                
        
        
        
        
makerem = []
for i in range(d):
    makerem.append(i)
    
print(search([],[],[],makerem,g,0))

Submission status: Time Limit Exceeded

Solution code:
#3
d,g = map(int,input().split())
lista = []
for i in range(d):
    lista.append([])
    p,c = map(int,input().split())
    lista[i] = [p,c]
    
def search(allcomp,notouch,touch,rem,toachiev,ps):
    #allcomp 全部解く
    #notouch 触らない
    #touch 触る
    #残りの選択肢
    #達成までに必要な得点
    #ここまで解いてる問題数
    if touch != []:
        #print(allcomp,notouch,touch,rem,toachiev,ps)
        point = (touch[0] + 1)*100
        problems = lista[touch[0]][0]
        vnus =  lista[touch[0]][1]
        #print(point,problems,vnus)
        if toachiev == 0:
            return ps
        else:
            needproblems = toachiev//point
            if toachiev%point != 0:
                needproblems += 1
                
            if needproblems<=problems:
                return ps+needproblems
            else:
                if point*problems + vnus >= toachiev:
                    return ps+problems
                else:
                    return 10**9
                
    else:
        if len(rem)==1:
            rempoint = (rem[0] + 1)*100
            notouchpoint_max = 0
            if notouch != []:
                notouchpoint_max = (max(notouch) + 1)*100
            
            if notouchpoint_max <= rempoint:
                return search(allcomp,notouch,rem,[],toachiev,ps)
            else:
                return 10**9
        else:
            minp = 10**9
            for i in range(len(rem)):
                allcomp_t,notouch_t,rem_t,toachiev_t,ps_t = list(allcomp),list(notouch),list(rem),toachiev,ps
                allcomp_t.append(rem[i])
                rem_t = rem[:i]+rem[i+1:]
                toachiev_t = toachiev_t - (rem[i] + 1)*100*lista[rem[i]][0] - lista[rem[i]][1]
                if toachiev_t <0:
                    toachiev_t = 0
                ps_t = ps_t + lista[rem[i]][0]
                case1 = search(allcomp_t,notouch_t,[],rem_t,toachiev_t,ps_t)
                
                allcomp_t,notouch_t,rem_t,toachiev_t,ps_t = list(allcomp),list(notouch),list(rem),toachiev,ps
                notouch_t.append(rem[i])
                rem_t = rem[:i]+rem[i+1:]
                case2 = search(allcomp_t,notouch_t,[],rem_t,toachiev_t,ps_t)
                #print(case1,case2)
                if minp > min(case1,case2):
                    minp = min(case1,case2)
                    
            return minp
                
        
        
        
        
makerem = []
for i in range(d):
    makerem.append(i)
    
print(search([],[],[],makerem,g,0))

Submission status: Time Limit Exceeded

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

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

def solve(count, problems, ff):
    if count == 0:
        return 0
    
    point_max = 0
    for i in range(d):
        nums, bonus = problems[i]
        point = (i + 1) * 100
        
        if nums == 0:
            continue
        
        if count >= nums:
            t = count - nums
            sum_point = point * nums + bonus
            if t > 0:
                # new list
                new_list = [] * d
                for j in range(d):
                    new_list.append([0, 0])
                    new_list[j][0] = problems[j][0]
                    new_list[j][1] = problems[j][1]
                new_list[i][0] = 0
                sum_point += solve(t, new_list, False)
            point_max = max(point_max, sum_point)
        else:
            point_max = max(point_max, count * point) 
            
    if ff == False:
        return point_max
            
    if point_max >= g:
        print(count)
        sys.exit()
    else:
        return solve(count + 1, ol, True)

solve(1, ol, True)

Submission status: Time Limit Exceeded

Solution code:

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

memo = dict()


def rec(crp, crscore, crans):
    global D, G, pc, memo

    if (crp, crscore) in memo:
        return memo[(crp, crscore)] + crans

    if crscore >= G:
        return crans
    elif crp > D:
        return 10**9

    p, c = pc[crp - 1]

    tmp_min = min(
        rec(crp + 1, crscore + 100 * crp * i, crans + i) for i in range(p)
    )

    res = min(tmp_min, rec(crp + 1, crscore + 100 * crp * p + c, crans + p))
    memo[(crp, crscore)] = res - crans
    return res


print(rec(1, 0, 0))

Submission status: Time Limit Exceeded

Solution code:

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

memo = dict()


def rec(crp, crscore, crans):
    global D, G, pc, memo

    if (crp, crscore, crans) in memo:
        return memo[(crp, crscore, crans)]

    if crscore >= G:
        return crans
    elif crp > D:
        return 10**9

    p, c = pc[crp - 1]

    tmp_min = min(
        rec(crp + 1, crscore + 100 * crp * i, crans + i) for i in range(p)
    )

    res = min(tmp_min, rec(crp + 1, crscore + 100 * crp * p + c, crans + p))
    memo[(crp, crscore, crans)] = res
    return res


print(rec(1, 0, 0))

Submission status: Time Limit Exceeded

Solution code:
D,P = map(int,input().split(' '))
p = [0 for i in range(D)]
c = [0 for i in range(D)]
ans_list = list()

def cal(index,cnt,score):
    if index == D-1:
        for i in range(p[index]+1):
            if i == p[index]:
                ans_list.append([score+c[index]+(index+1)*100*i,cnt+i])
            else:
                ans_list.append([score+(index+1)*100*i,cnt+i])
    else:
        for i in range(p[index]+1):
            if i == p[index]:
                cal(index+1,cnt+i,score+c[index]+(index+1)*100*i)
            else:
                cal(index+1,cnt+i,score+(index+1)*100*i)


for i in range(D):
    p[i],c[i] = map(int,input().split(' '))
    
cal(0,0,0)
# print(ans_list)
print(min([b for a,b in ans_list if P<=a]))

Submission status: Time Limit Exceeded

Solution code:
D, G = map(int, input().split())
G //= 100
problems = []
for i in range(D):
    b = i + 1
    p, c = map(int, input().split())
    c //= 100
    problems.append((b, p, c))  # 基本点, 問題数, ボーナス

nsolved = {0: 0}  # 総合点 → 必要問題数

for b, p, c in problems:
    nsolved2 = {}
    for k in nsolved:
        for n in range(p + 1):
            s = b * n + (0 if n < p else c)  # n問解いたときの総合点
            g = min(k + s, G)                # 総合点
            if g not in nsolved2:
                nsolved2[g] = nsolved[k] + n
            else:
                nsolved2[g] = min(nsolved2[g], nsolved[k] + n)
    nsolved = nsolved2

print(nsolved[G])

Submission status: Time Limit Exceeded

Solution code:
D, G = map(int, input().split())
problems = []
for i in range(D):
    b = (i + 1) * 100
    p, c = map(int, input().split())
    problems.append((b, p, c))  # 基本点, 問題数, ボーナス

nsolved = {0: 0}  # 総合点 → 必要問題数

for b, p, c in problems:
    nsolved2 = {}
    for k in nsolved:
        for n in range(p + 1):
            s = b * n + (0 if n < p else c)  # n問解いたときの総合点
            g = min(k + s, G)                # 総合点
            if g not in nsolved2:
                nsolved2[g] = nsolved[k] + n
            else:
                nsolved2[g] = min(nsolved2[g], nsolved[k] + n)
    nsolved = nsolved2

print(nsolved[G])

Submission status: Time Limit Exceeded

Solution code:
from itertools import dropwhile as dw

D,G = map(int, input().split(' '))
p_dict = {}
op = []
for i in range(D):
    j, k = map(int, input().split(' '))
    op += [100*(i+1)] * j
    p_dict[i] = (j, k)

leng = len(op)
min_op = 10 ** 8
for i in range(2 ** leng):
    op_list = op.copy()
    for j in range(leng):
        if ((i >> j) & 1):
            op_list[-1*(j+1)] = 0
    result = sum(op_list)
    op_list.sort()
    count = len(list(dw(lambda x: x == 0, op_list)))
    for k in p_dict.keys():
        if op_list.count(100*(k+1)) == p_dict[k][0]:
            result += p_dict[k][1]
    if result >= G and count < min_op:
        min_op = count
print(min_op)

Submission status: Time Limit Exceeded

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

def counter_repeat(num, array):
	current = 0
	for i in range(len(array)):
		counter = 0 
		b = (i + 1) * 100 * array[i][0]
		if b + array[i][1] >= num:

			if b >= num:
				counter += -(-1 * num // ((i + 1) * 100))
			else:
				counter += array[i][0]
		else:
			c = array[:]
			c.pop(i)
			counter += array[i][0] + counter_repeat(num - (b + array[i][1]), c)
		if i == 0:
			current = counter
		else:
			if current > counter:
				current = counter
	return current
print(counter_repeat(g, a))

Submission status: Time Limit Exceeded

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

def counter_repeat(num, array):
	current = 0
	for i in range(len(array)):
		counter = 0 
		b = (i + 1) * 100 * array[i][0]
		#print(num, b)
		if b + array[i][1] >= num:

			if b >= num:
				d = ((i + 1) * 100)
				counter += num // d
				if num % d != 0:
					counter += 1
				#print(1, counter)
				#print(current, counter)

			else:

				counter += array[i][0]
				#print(2, counter)

		else:
			c = array[:]
			c.pop(i)

			counter += array[i][0]
			#print(3,counter)
			counter += counter_repeat(num - (b + array[i][1]), c)
		if i == 0:
			current = counter
		else:
			if current > counter:
				current = counter

	return current

print(counter_repeat(g, a))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

d, g = map(int, input().split())
points_list = []
for i in range(d):
    p, c = map(int, input().split())
    points = []
    for j in range(p):
        point = [j, (i + 1) * 100 * j]
        points.append(point)
    points.append([j + 1, (i + 1) * 100 * (j + 1) + c])
    points_list.append(points)

total = np.array(points_list.pop())
for points in points_list:
    subtotal = np.array([[0,0]])
    for point in points:
        subtotal = np.append(subtotal, total + point, axis = 0)
    total = np.array(subtotal)

print(min(total[total[:,1] >= g][:,0]))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
import itertools
import collections
import functools
import math
from queue import Queue
INF = float("inf")


def solve(D: int, G: int, p: "List[int]", c: "List[int]"):

    scores = []
    for i, (pp, cc) in enumerate(zip(p, c)):
        s = [100*(i+1)]*pp
        s[-1] += cc
        scores.append(s)

    m = INF
    for l in itertools.permutations(range(D), D):
        junjo = []
        for ll in l:
            junjo.extend(scores[ll][:])
        s = 0
        for i, ju in enumerate(junjo):
            s += ju
            if s >= G:
                break
        # print(l, i+1, junjo)
        m = min(m, i+1)
    print(m)
    return


def main():

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
D, G = (int(num) for num in input().split())
lis_pc = []
for i in range(D):
    lis_pc.append([int(num) for num in input().split()])
    
def dfs(cnt,pr,s):
    if cnt == D:
        if s < G:
            return 50000000000000000
        else:
            return pr
    else:
        p,c = lis_pc[cnt]
        m = dfs(cnt+1,pr+p,s+100*(cnt+1)*p+c)
        for i in range(p):
            m_tmp = dfs(cnt+1,pr+i,s+100*(cnt+1)*i)
            if m_tmp < m:
                m = m_tmp
        return m
                
                
print(dfs(0,0,0))

Submission status: Time Limit Exceeded

Solution code:
import sys

d, g = [int(x) for x in input()[:-2].split()]
pc = [[int(x) for x in input()[:-2].split()] for _ in range(d)]

def dfs(choice):
    if len(choice) == d:
        if sum(x * (i + 1) + (ci if x == pi else 0) for i, (x, (pi, ci)) in enumerate(zip(choice, pc))) >= g:
            return sum(choice)
        else:
            return sys.maxsize
    else:
        return min(dfs(choice[:] + [x]) for x in range(pc[len(choice)][0] + 1))

print(dfs([]))

Submission status: Time Limit Exceeded

Solution code:
import itertools as it
D, G = map(int, input().split())
P, C = [], []
for _ in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)
A = list(it.permutations([i for i in range(D)]))
ans = 10**9
for a in A:
    S, i, sub_ans = 0, 0, 0
    while 1:
        if S + (a[i] + 1) * 100 * P[a[i]] < G:
            S += (a[i] + 1) * 100 * P[a[i]]
            sub_ans += P[a[i]]
            S += C[a[i]]
        else:
            j = 0
            while S < G and j < P[a[i]]:
                S += (a[i] + 1) * 100
                sub_ans += 1
            if j == P[a[i]]:
                S += C[a[i]]
        if S >= G:
            if sub_ans < ans:
                ans = sub_ans
            break
        i += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
ans=1000
D,G=map(int,input().split())
l=[]
for i in range(D):
  a,b=map(int,input().split())
  l.append([(i+1)*100,a,b])
for comb in itertools.permutations(range(D)):
  kans=0
  g=G
  for i in range(D):
    j=comb[i]
    if l[j][0]*l[j][1]<=g:
      g-=l[j][0]*l[j][1]+l[j][2]
      kans+=l[j][1]
      if g<=0:
        break
    else:
      kans+=g//l[j][0] if g%l[j][0]==0 else g//l[j][0]+1
      break
  ans=min(ans,kans)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
d, g = map(int, input().split())
a = []
c = []
for i in range(d):
    a.append(list(map(int, input().split())))
itr = [i for i in range(d)]
p = list(itertools.permutations(itr, len(itr)))
for b in p:
    count = 0
    r = g
    for i in b:
        if r <= 0:
            break
        temp = (i+1) * 100
        l = [temp] * a[i][0]
        l[-1] += a[i][1]
        for j in range(len(l)):
            count += 1
            r -= l[j]
            if r <= 0:
                c.append(count)
                break
print(min(c))

Submission status: Time Limit Exceeded

Solution code:
from itertools import permutations
from math import ceil
D, G = map(int, input().split())
prob = [tuple(map(int, input().split())) for _ in range(D)]
perms = [i for i in range(D)]
ans = 10 ** 100
for p in permutations(perms):
    point = 0
    manip = 0
    for i in range(D):
        if point + (p[i] + 1) * 100 * (prob[p[i]][0] - 1) >= G:
            manip += ceil((G - point) / ((p[i] + 1) * 100))
            ans = min(ans, manip)
            break
        else:
            point += (p[i] + 1) * 100 * prob[p[i]][0] + prob[p[i]][1]
            manip += prob[p[i]][0]
            if point >= G:
                ans = min(ans, manip)
                break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
D,G=list(map(int,input().split()))
p=np.zeros(D)
c=np.zeros(D)
for i in range(D):
    a,b=list(map(int,input().split()))
    p[i]=a
    c[i]=b
    
def solve(x):  
    score=0
    cost=0
    no_use_list=[] #全問解かない点数を格納
    
    b=str(format(x,'010b'))
    for i in range(1,D+1):
        if b[-i]=="1": #全問解答する
            score+=100*i*p[i-1]+c[i-1]
            cost+=p[i-1]
        else:
            no_use_list.append(i-1)

    if score<G: #足りていない場合
        no_use_list=no_use_list[::-1]
        for j in no_use_list:
            no_solve=p[j]-1
            while(no_solve!=0):
                score+=100*(j+1)
                cost+=1
                if score>=G:
                    return cost
                no_solve-=1
                
    if score<G:
        return 10**9+7
    return cost

min_cost=10**9+7
for x in range(2**D):
    cost=solve(x)
    if cost<min_cost:
        min_cost=cost
print(int(min_cost))

Submission status: Time Limit Exceeded

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

def score():
	return

def choise_r(count, l, score, G):
	"再帰的に、問題選択の全パターンを集計する"
	for i in range(len(l)):
		l_t = copy.deepcopy(l)
		# 空の問題はスキップ
		if l_t[i][0] <= 0:
			continue
		# 選択した問題を加算
		score_n = score + 100 * (i + 1)
		l_t[i][0] -= 1
		if l_t[i][0] <= 0:
			score_n += l_t[i][1]
		if G <= score_n:
			return True
		if (0 < count):
			if choise_r(count - 1, l_t, score_n, G):
				return True
	return False

def main():
	D, G = map(int, input().split())
	l = [list(map(int, input().split())) for _ in range(D)]
	for i in range(100):
		if choise_r(i, l, 0, G):
			print(i + 1)
			return

if __name__ == '__main__':
	main()

Submission status: Time Limit Exceeded

Solution code:
# /user/bin/python
# -*- coding: utf-8 -*-
import sys
import numpy as np


D,G = map(int, sys.stdin.readline().rstrip().split())
G //= 100
P = [0]
C = [0]
for _ in range(D):
  p,c = map(int, sys.stdin.readline().rstrip().split())
  P.append(p)
  C.append(c//100)


dp = [[sys.maxsize for j in range(G+1)] for i in range(D+1)]
for i in range(D+1):
  dp[i][0] = 0

for i in range(1,D+1):
  for j in range(1,G+1):
    for q in range(P[i]):
      dp[i][j] = min(dp[i][j], dp[i-1][max(0, j-i*q)] + q)
    q = P[i]
    dp[i][j] = min(dp[i][j], dp[i-1][max(0, j-i*q-C[i])] + q)

print(dp[D][G])

Submission status: Time Limit Exceeded

Solution code:
D, G=list(map(int, input().split()))
#L[i][0]:i番目の問題数、L[i][0]:i番目のボーナス得点 調整のため[0]追加
L=[0]+[list(map(int, input().split())) for i in range(D)]
#f:i番目まで考えるときの最小問題数  
def f(G, i):
    l=[]
    if i==0:
        return 1000
    else:
    #j:i番目の問題を解く数
        for j in range(min(G//(i*100), L[i][0])+1):
            g=G-j*i*100
            #i番目でボーナス獲得し、足りない点数をi-1番目までで補うとき
            if j==L[i][0] and g-L[i][1]>0:
                l.append(f(g-L[i][1],i-1)+j)
            #i番目でボーナス獲得し、それで点数が足りる時
            elif j==L[i][0] and g-L[i][1]<=0:
                l.append(L[i][0])
            #i番目でボーナス獲得せず、足りない点数をi-1番目までで補うとき
            elif g>0:
                l.append(f(g,i-1)+j)
            #i番目でボーナス獲得せず、それで点数が足りる時
            elif g<=0:
                l.append(j)
                break
        return min(l)
print(f(G,D))

Submission status: Time Limit Exceeded

Solution code:
D, G=list(map(int, input().split()))
#L[i][0]:i番目の問題数、L[i][0]:i番目のボーナス得点 調整のため[0]追加
L=[0]+[list(map(int, input().split())) for i in range(D)]
#f:i番目まで考えるときの最小問題数  
def f(G, i):
    l=[]
    if i==0:
        return 10000 
    for j in range(min(G//(i*100), L[i][0])+1):
        if j==L[i][0] and G-j*i*100-L[i][1]>0:
            l.append(f(G-j*i*100-L[i][1],i-1)+j)
        elif j==L[i][0] and G-j*i*100-L[i][1]<=0:
            l.append(L[i][0])
        elif G-j*i*100>0:
            l.append(f(G-j*i*100,i-1)+j)
        elif G-j*i*100<=0:
            l.append(j)
        else:break
    return min(l)

print(f(G,D))

Submission status: Time Limit Exceeded

Solution code:
#2-1-1 #ABC104C
d,g=map(int,input().split())
q=[]
bornus=[]
for i in range(d):
    p,c=map(int,input().split())
    q.append(p)
    bornus.append(c)
from collections import defaultdict
data=defaultdict(set)
data[0]|={(0 for i in range(d)),}
def makesolve(q,k):
    before=data[k-1].copy()
    for i in before:
        ii=list(i)
        for j in range(d):
            if ii[j]<q[j]:
                ico=ii.copy()
                ico[j]+=1
                data[k]|={tuple(ico),}
    
def calc(q,bornus,solve):
    point=0
    for i in range(d):
        point+=solve[i]*(i+1)*100
        if solve[i]==q[i]:
            point+=bornus[i]
    return point

ans=sum(q)
for i in range(1,sum(q)+1):
    makesolve(q,i)
    for j in data[i]:
        if calc(q,bornus,j)>=g:
            ans=i
            break
    if ans<sum(q):break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
D,G=map(int,input().split())
p=[0]*D
c=[0]*D
ans=1000000000
for i in range(D):
    p[i],c[i]=map(int,input().split())
for i in range(1<<D):
    s=0
    cnt=0
    P=[0]*D
    for j in range(D):
        if ((i>>j)&1)==1:
            s+=c[j]+(j+1)*p[j]*100
            cnt+=p[j]
            P[j]=1
    while s<G:
        for k in range(D):
            if s>=G:
                break
            if P[D-k-1]==0:
                for l in range(p[D-k-1]-1):
                    if s>=G:
                        break
                    else:
                        s+=(D-k)*100
                        cnt+=1
    if cnt<ans:
        ans=cnt
print(ans)

Submission status: Time Limit Exceeded

Solution code:
D,G=map(int,input().split())
p=[0]*D
c=[0]*D
ans=1000000000
for i in range(D):
    p[i],c[i]=map(int,input().split())
for i in range(1<<D):
    s=0
    cnt=0
    P=[0]*D
    for j in range(D):
        if ((i>>j)&1)==1:
            s+=c[j]+(j+1)*p[j]*100
            cnt+=p[j]
            P[j]=1
    while s<G:
        for k in range(D):
            if P[D-k-1]==0:
                for l in range(p[D-k-1]-1):
                    if s>=G:
                        break
                    else:
                        s+=(D-k)*100
                        cnt+=1
    if cnt<ans:
        ans=cnt
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

min_count = sum(p)
for i in range(2**sum(p)):
    temp_sum = 0
    temp_count = 0
    bit = 0
    for j in range(d):
        problem_bit = 2**p[j] - 1
        target_bit = i >> bit & problem_bit
        if target_bit == problem_bit:
            # ボーナス
            temp_sum += c[j]
        count = int(bin(target_bit).count("1"))
        temp_sum += count*(j+1)*100
        temp_count += count
        bit += p[j] - 1
        if g <= temp_sum or count > min_count:
            # これ以上続ける必要なし
            break
    if g <= temp_sum and temp_count < min_count:
        min_count = temp_count
print(min_count)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

min_count = sum(p)
for i in range(2**sum(p)):
    temp_sum = 0
    temp_count = 0
    bit = 0
    for j in range(d):
        problem_bit = 2**p[j] - 1
        target_bit = i >> bit & problem_bit
        if target_bit == problem_bit:
            # ボーナス
            temp_sum += c[j]
        count = int(bin(target_bit).count("1"))
        temp_sum += count*(j+1)*100
        temp_count += count
        bit += p[j] - 1
        if g <= temp_sum:
            break
    if g <= temp_sum and temp_count < min_count:
        min_count = temp_count
print(min_count)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

min_count = sys.maxsize
for i in range(2**sum(p)):
    temp_sum = 0
    temp_count = 0
    bit = 0
    for j in range(d):
        if g <= temp_sum:
            break
        for k in range(p[j]):
            if i >> (bit+j+k) & 1 == 1:
                temp_sum += (j+1)*100
                temp_count += 1
        all_true = 2**p[j] - 1
        if (i >> bit & all_true) == all_true:
            # ボーナス
            temp_sum += c[j]
        bit += p[j] - 1
    if g <= temp_sum and temp_count < min_count:
        min_count = temp_count
print(min_count)

Submission status: Time Limit Exceeded

Solution code:
from itertools import permutations
from math import ceil

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

perBase = [i for i in range(D)]
res = 999999
for per in permutations(perBase):
    cnt = 0
    score = 0
    for i in range(D):
        pid = per[i]
        p = pc[pid][0]
        c = pc[pid][1]
        once = 100*(pid+1)
        adder = p * once
        if score + adder >= G:
            left = G-score
            cnt += ceil(left/once)
            break
        if score + adder + c >= G:
            score += adder
            cnt += p
            break
        score += adder + c
        cnt += p
    res = min(res,cnt)
print(res)

Submission status: Time Limit Exceeded

Solution code:
import itertools

D,G = list(map(int,input().split()))
d = []
ans = (10e10)

for i in range(D):
    a,b = list(map(int,input().split()))
    d.append([100*(i+1) for j in range(a-1)])
    d[i].append(100*(i+1)+b)

for ar in itertools.permutations(d):
    num = cnt = 0
    for i in ar:
        if num+sum(i) < G:
            num += sum(i)
            cnt += len(i)
        else:
            for j in i:
                if num+j < G:
                    num += j
                    cnt += 1
                else:
                    ans = min(ans,cnt+1)
                    break
            break
        
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

D,G = list(map(int,input().split()))
d = []
ans = (10e10)

for i in range(D):
    a,b = list(map(int,input().split()))
    d.append([100*(i+1) for j in range(a-1)])
    d[i].append(100*(i+1)+b)

for ar in itertools.permutations(d):
    num = cnt = 0
    for i in ar:
        if num+sum(i) < G:
            num += sum(i)
            cnt += len(i)
        else:
            for j in i:
                if num+j < G:
                    num += j
                    cnt += 1
                else:
                    ans = min(ans,cnt+1)

print(ans)