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

Solution code:
## coding: UTF-8
from itertools import permutations, combinations,combinations_with_replacement,product
s = input().split()
t = [int(p) for p in s]
#print(t[0])
#print(t[1])
D = t[0] #点数の種類数(D * 100点まである)
G = t[1] #ゴールとなる得点数
number_bonus = [] #要素D個の[問題数、ボーナス]のセット

for i in range(D):
    u = input().split()
    v = [int(p) for p in u]
    number_bonus.append(v)

#print('D:{}'.format(D))
#print('G:{}'.format(G))
#print('number_bonus:{}'.format(number_bonus))

problem_counter = 0 #問題数を数える
a=list(product([0,1],repeat=D)) #組み合わせを全パターン出してくれる D=10なら[0, 0, 1, 1, 0, 1, 0, 1, 0, 1]みたいな感じで出してくれる。
#print(a) #len(a) = 2^D


counter = [] #a全てのパターンについて問題数を返して格納する
for i in range(len(a)): #a全てのパターンについて試す
    #print('i:{}'.format(i))
    getpoint = 0 #獲得点数を毎回初期化する
    problem_counter = 0 #問題数数え上げを毎回初期化する
    #要素が0のうちindexが最大なもののindexをとる
    max_0_index = -1
    for k in range(D):
        if(a[i][k] == 0):
            max_0_index = k
    #print('i:{},max_0_index:{}'.format(i, max_0_index))
    for j in range(D):
        if(a[i][j] == 1):
            getpoint += (j+1) * 100 * number_bonus[j][0] +  number_bonus[j][1]#(j+1)*100点問題をnumber_bonus[j][0]問といて,number_bonus[j][1]点のボーナスをもらう
            problem_counter += number_bonus[j][0]
    #print('i:{},allgetpoint:{},problem_counter:{}'.format(i,getpoint,problem_counter))
    if(getpoint >= G):
        counter.append(problem_counter) #Gを超えていれば「条件を満たす問題数」として出力（最小値を取るので大きな値を取っちゃっても問題ない）
        #print('problem_counter:{}問で条件を満たしました'.format(problem_counter))
#    if(getpoint == G):
#        counter.append(problem_counter) #Gちょうどだったらここで終了して問題数を格納
    if(getpoint < G):
        #max_0_indexの問題をGを超えるまでとく
        #(max_0_index + 1) * 100点の問題
        #問題数:number_bonus[max_0_index][0]
        #ボーナス特典は関係ない（全部解いて初めて0を
        for i in range(number_bonus[max_0_index][0]):
            if(getpoint >= G):
                continue #Gを超えたらもう足さない
            getpoint += (max_0_index + 1) * 100
            problem_counter += 1
        #ループを終えた後にGを超えたか確認する
        if(getpoint >= G):
            counter.append(problem_counter)
            #print('problem_counter:{}問で条件を満たしました'.format(problem_counter))
#print(counter)

print(min(counter))







'''
#解く順番を指定するリストを順列で生成
p = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
order = list(permutations(p[:D], D)) #D!個生成される
print(order)

def all_solve(haiten, point, bonus):
    return haiten * point + bonus


getpoint = 0
problem_counter = 0
index = 0
order_index = 0
while True:
    point_bonus_index = int(order[index][order_index] - 1)
    print(point_bonus_index)
    if(getpoint + all_solve(order[index][order_index] * 100, point_bonus[point_bonus_index][0], point_bonus[point_bonus_index][1])   <  G ):
        getpoint+=all_solve(order[index][order_index] * 100, point_bonus[point_bonus_index][0], point_bonus[point_bonus_index][1])
        problem_counter +=point_bonus[point_bonus_index][0]
        order_index+=1
        print('getpoint:{}, problem_counter:{}'.format(getpoint,problem_counter))
    else:
        break
print('getpoint:{}, problem_counter:{}'.format(getpoint,problem_counter))
'''
'''
alpha = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
haiten_list = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
#use_alpha = alpha[:D]
#print(use_alpha)
a = list(permutations(haiten_list[:D], D))
#print(a)


def all_solve(haiten, p_i, c_i):
    return haiten * p_i + c_i
#print(haiten_list[2], p_c_[2][0], p_c_[2][1])
#print(all_solve(haiten_list[2], p_c_[2][0], p_c_[2][1]))

def count_problem(solve_list, G):
    getpoint = 0
    counter = 0
    i = 0
    while getpoint+all_solve(solve_list[i], p_c_[int(solve_list[i]/100.0)-1][0], p_c_[int(solve_list[i]/100.0)-1][1]) < G:
        getpoint += all_solve(solve_list[i])
        counter += p_c_[int(solve_list[i]/100)-1][0]
        print(counter)
count_problem(a, G)
'''

Submission status: Accepted

Solution code:
D, G = map(int, input().split())
questions = []
for a in range(D):
    question = []
    p, c = input().split()
    question.append(int(p))
    question.append(int(c))
    questions.append(question)
numbers = []
S=[i for i in range(D)]
T=tuple(S)
for i in range(2 ** D):
    number = []
    for j in range(D):
        if ((i >> j) & 1):
            number.append(j)
    numbers.append(number)
del numbers[0]
answers=[]
for a in range(1, questions[D - 1][0]):
    b = D * 100 * a
    if G <= b:
        answers.append(a)
for a in numbers:
    goukei = 0
    suuji=0
    for b in a:
        goukei+=questions[b][0]*(b+1)*100+questions[b][1]
        suuji+=questions[b][0]
    if goukei>=G:
        answers.append(suuji)
    else:
        U = list(T)
        for c in range(len(a)):
            if a[c] in U:
                U.remove(a[c])
        saidai = max(U)
        rest=G-goukei
        kaisuu=rest//((saidai+1)*100)
        if kaisuu<questions[saidai][0]:
            answers.append(suuji+kaisuu)
print(min(answers))

Submission status: Accepted

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

p = []
c = []
for i in range(D):
    a,b = list(map(int,input().split()))
    p.append(a)
    c.append(b)
ans = 10**9
for i in range(2**D):
    score = 0
    count = 0
    #print(list(bin(i+2**D)[3:]))
    #print(list(bin((2**(D+1)-1) ^ i)[3:][::-1]))
    for j,s in enumerate(list(bin(i+2**D)[3:])):
        if s=="1":
            score+=c[j] + p[j]*100*(j+1)
            count+=p[j]
    rev = list(bin((2**(D+1)-1) ^ i)[3:][::-1])
    #print(rev)
    #print(rev[0])
    for j in range(D):
        #print(score,rev[j])
        if G <= score:
            break
        if rev[j]=="1":
            if (G-score)//((D-j)*100)<p[D-j-1]-1:
                if (G-score)%((D-j)*100)==0:
                    count+=(G-score)//((D-j)*100)
                    score+=((G-score)//((D-j)*100))*((D-j)*100)
                else:
                    count+=(G-score)//((D-j)*100)+1
                    score+=((G-score)//((D-j)*100)+1)*((D-j)*100)
                
                break
            else:
                score+=(p[D-j-1]-1)*(D-j)*100
                count += p[D-j-1]-1

    if G<=score:
        ans = min(count,ans)

print(ans)

Submission status: Accepted

Solution code:
d,g=map(int,input().split())
num=[0 for _ in range(d)]
com=[0 for _ in range(d)]
hum=[100*(i+1) for i in range(d)]
ans=10**9+7
for i in range(d):
    num[i],com[i]=map(int,input().split())
for i in range(2**d):
    tmp_get=0
    tmp_ans=0
    for j in range(d):
        if((i>>j)&1):
            tmp_get+=num[-j-1]*hum[-j-1]
            tmp_get+=com[-j-1]
            tmp_ans+=num[-j-1]
    for j in range(d):
        if tmp_get>=g:
            break        
        if not((i>>j)&1):
            tmp_cnt=min(-(-(g-tmp_get)//hum[-j-1]),num[-j-1])
            tmp_ans+=tmp_cnt
            tmp_get+=tmp_cnt*hum[-j-1]
            if tmp_cnt==num[-j-1]:
                tmp_get+=com[-j-1]
    ans=min(ans,tmp_ans)
print(ans)

Submission status: Accepted

Solution code:
#n進数への変換関数の定義
#Python 3.7とかではデフォであるが，Python 3.4.3(AtCoder仕様)ではまだない
########10進法からn進法への変換関数部分##############
def format(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
############################

########10進法からn進法への変換関数(m桁埋める)部分##############
def format0(X, n, m):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    if len(out) < m:
        out = "0" * (m - len(out)) + out
    return out
############################
d,g=map(int,input().split())
pc=[list(map(int,input().split())) for i in range(d)]
ans=1000

for i in range(pow(2,d)):
  pt=0
  ans_=0
  t = format0(i,2,d)
  for j in range(d):
    if t[j]=="1":
      pt += (j+1)*100*pc[j][0]+pc[j][1]
      ans_ += pc[j][0]
  if pt >= g:
    ans = min(ans,ans_)
    continue
  for j in range(d):
    j=d-1-j
    if t[j]=="1":
      continue
    if pt + ((j+1)*100*(pc[j][0]-1))>=g:
      q=(j+1)*100
      k = (g-pt+q-1)//q
      pt += (j+1)*100*k
      ans_ += k
      break
    else:
      pt += (j+1)*100*(pc[j][0]-1)
      ans_ += pc[j][0]-1
  if pt>=g:
    ans = min(ans,ans_)
print(ans)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/arc026/tasks/arc026_2
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  d,g=LI()
  l=[LI() for _ in range(d)]

  ans=inf
  for i in range(2**d):
    sm=0
    cnt=0
    _l=[0]*d
    for j in range(d):
      if i&(1<<j):
        cnt+=l[j][0]
        sm+=l[j][0]*(j+1)*100+l[j][1]
        _l[j]=1

    if sm<g:
      while True:
        for k in range(d)[::-1]:
          if _l[k]==0:
            _l[k]=2 # for debug
            if sm+(k+1)*100*(l[k][0]-1)>=g:
              _cnt=(g-sm+(k+1)*100-1)//((k+1)*100)
              cnt+=_cnt
              sm+=_cnt*(k+1)*100
              break
            else:
              cnt+=l[k][0]-1
              sm+=(k+1)*100*(l[k][0]-1)

        break

    if sm>=g:
      ans=min(ans,cnt)

    # print(cnt,sm,_l)

  return ans

# main()
print(main())

Submission status: Accepted

Solution code:
def dfs(i, sum, cnt, memo):
    if i == d + 1:
        if sum >= g:
            tmp.append(cnt)
        else:
            cnt += min(p_lst[max(memo) - 1], -(-(g - sum) // (max(memo) * 100)))
            if sum + min(p_lst[max(memo) - 1], -(-(g - sum) // (max(memo) * 100))) * max(memo) * 100 >= g:
                tmp.append(cnt)
        
    else:
        dfs(i + 1, sum + 100 * i * p_lst[i - 1] + c_lst[i - 1], cnt + p_lst[i - 1], memo)
        dfs(i + 1, sum, cnt, memo + [i])

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


dfs(1, 0, 0, [])
print(min(tmp))

Submission status: Accepted

Solution code:
from itertools import product

d, g = [int(i) for i in input().split()]
p = []
c = []
for _ in range(d):
    ipt = [int(i) for i in input().split()]
    p.append(ipt[0])
    c.append(ipt[1])

res = 100*10+1
for solved in product((0, 1),repeat=d):
    cnt = score = max_i = 0
    for i, prob in enumerate(solved):
        if prob:
            cnt += p[i]
            score += p[i] * 100 * (i+1) + c[i]
        else:
            max_i = i

    if score < g:
        for _ in range(p[max_i]):
            cnt += 1
            score += 100 * (max_i+1)
            if score >= g:
                break

    if score >= g and cnt < res:
        res = cnt

print(res)

Submission status: Accepted

Solution code:
import itertools

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

res = 1000000
for i in itertools.product([0, 1], repeat=D):
    cost = 0
    num = 0
    for j in range(len(i)):
        cost += ((j+1)*100*P[j][0]+P[j][1])*i[j]
        num += P[j][0]*i[j]
    #print(i, cost, num, res)
    if cost >= G:
        res = min(res, num)
    else:
        for k in range(len(i)-1, -1, -1):
            if i[k] == 1:
                continue
            for l in range(P[k][0]):
                cost += 100*(k+1)
                num += 1
                if cost >= G:

                    res = min(res, num)
                    break
        else:
            continue
        break

print(res)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2000)

D, goal = map(int, input().split())
q_num, bonus = [], []
for i in range(1,D+1):
  q, b = map(int, input().split())
  q_num.append(q)
  bonus.append(b)
ans = 100000

def rec2(current_qn, next_n, current_score, tyuuto_done):
  if next_n == D + 1:
    global ans
    if current_score >= goal:
      ans = min(ans, current_qn)
  else:
    rec2(current_qn+q_num[next_n-1], next_n+1, current_score+q_num[next_n-1]*next_n*100+bonus[next_n-1], tyuuto_done)
    rec2(current_qn, next_n+1, current_score, tyuuto_done)
    if not tyuuto_done:
      for i in range(1,q_num[next_n-1]):
        rec2(current_qn+i, next_n+1, current_score+i*next_n*100, 1)

def rec(comb, next_n, current_score):
  if next_n == D + 1:
    global ans
    if current_score >= goal:
      ans = min(ans, sum(comb))
  else:
    for i in range(q_num[next_n-1]):
      rec(comb + [i], next_n+1, current_score + i * next_n * 100)
    rec(comb + [q_num[next_n-1]], next_n+1, current_score + q_num[next_n-1] * next_n * 100 + bonus[next_n-1])

# rec([], 1, 0)
rec2(0, 1, 0, 0)

print(ans)

Submission status: Accepted

Solution code:

inf=10**10

d,g=map(int,input().split())
g//=100
p=[];c=[]
for i in range(d):
    a,b=map(int,input().split())
    b//=100
    p.append(a)
    c.append(b)
ans=inf

for i in range(1<<d):
    cnt=0
    sum=0
    for j in range(d):
        if(i&(1<<j)):
            cnt+=p[j]
            sum+=(j+1)*p[j]+c[j]
    for j in range(d)[::-1]:
        if(i&(1<<j)):continue
        if(sum>=g):break
        if(sum+(j+1)*(p[j]-1)<=g):
            cnt+=p[j]-1
            sum+=(j+1)*(p[j]-1)
        else:
            cnt+=(g-sum+j)//(j+1)
            sum=inf
            
    if(sum>=g):ans=min(ans,cnt)
    #print(i,cnt,sum)
print(ans)

Submission status: Accepted

Solution code:

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

D, G = MAP()
pc = [LIST() for i in range(D)]

B = list(product([0, 1], repeat=D))

ans = INF
for b in B:
    point = 0
    count = 0
    for i, vonus in enumerate(b):
        if vonus == 1:
            # take all with vonus
            point += pc[i][0] * (i + 1) * 100 + pc[i][1]
            count += pc[i][0]
        # print(count)
    if point >= G:
        ans = min(count, ans)
        # print(count)
    else:
        # 後ろから
        need_point = G - point
        added_count = count
        for i in range(len(b)-1, -1, -1):
            if b[i] == 0:
                # while need_point > 0:
                    # count_max = pc[i][0]
                    num = ceil(need_point / (100 * (i + 1)))
                    if num >= pc[i][0]:
                        ###?
                        count = INF
                        break
                    count += ceil(need_point/ ((i+1) * 100))
                    break
                    # if need_point - point_max >= 0:
                    #     need_point -= point_max
                    #     count += count_max
                    # else:
                    #     count += ceil(need_point / (100 * (i + 1)))
                    #     need_point -= point_max
        ans = min(ans, count)
print(ans)

Submission status: Accepted

Solution code:
from itertools import product
import math
D,G = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(D)]
cmin = 10**4
for x in product((0,1),repeat=D):
    scr = 0
    cnt = 0
    j = -1
    for i in range(D):
        if x[i]==1:
            scr += 100*(i+1)*A[i][0]+A[i][1]
            cnt += A[i][0]
        else:
            j = i
    if scr>=G:
        cmin = min(cmin,cnt)
    else:
        k = math.ceil((G-scr)/(100*(j+1)))
        if k<A[j][0]:
            cmin = min(cmin,cnt+k)
print(cmin)

Submission status: Accepted

Solution code:
D,G = map(int, input().split())
G //= 100
PC = []
for _ in range(D):
    p,c = map(int, input().split())
    PC.append((p,c // 100))

ans = float("inf")
for i in range(2 ** D):
    cnt, scr = 0, 0
    smax = -1 # 未回答問題で最高配点
    for j in range(D):
        if (i >> j) & 1:
            p,c = PC[j]
            cnt += p
            scr += c + p * (j + 1)
        else:
            smax = j + 1

    if scr < G:
        need = (G - scr + smax - 1) // smax
        # 完答or問題数が足りない場合
        if need >= PC[smax - 1][0]:
            continue
        cnt += need
    
    ans = min(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
D, G = map(int, input().split())
P, comp = [], []
r = 0
for i in range(D):
  p, c = map(int, input().split())
  P.append(p), comp.append(100 * (i+1) * p + c)
  r += p
for i in range(1<<D):
  _g, _r = 0, 0
  for j in range(D):
    if i>>j & 1:
      _g += comp[j]
      _r += P[j]
  if _g >= G:
    r = min(r, _r)
    continue
  for j in range(D):
    if i>>j & 1:
      continue
    _diff = G - _g
    _p = 100 * (j+1)
    x = int(_diff // _p)
    if _diff % _p > 0:
      x += 1
    if x <= P[j]:
      _r += x
      r = min(r, _r)
print(r)

Submission status: Accepted

Solution code:
import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

# cnt = 0
# def count():
#     global cnt
#     cnt+=1
#     print(cnt)

def flag(point,P,now):
    if point+100*(now+1)*(P-1) >= g: return 1
    elif point+100*(now+1)*P + C[now] >= g: return 2
    else: return 0

m = 10**9
def score(point = 0, n = 0, now=-1, remain = list(range(d))):
    global m
    if m <= n: return
    elif now == -1:
        for i in remain:
            score(point, n, i, remain)
    elif point >= g: m = n
    elif flag(point,P[now],now) == 1:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: m = n
    elif flag(point,P[now],now) == 2:
        n += P[now]
        if m > n: m = n
    else:
        if m <= n+P[now]: return
        else:
            remain = remain[:]
            remain.remove(now)
            nxtp = point + P[now]*100*(now+1) + C[now]
            for i in remain:
                score(nxtp, n + P[now], i, remain)

score()
print(m)

Submission status: Accepted

Solution code:
import copy
N,G=map(int,input().split())
pc=[]
for i in range(N):
  pc.append(list(map(int,input().split())))
ans=10**10
for i in range(2**N):
  tmp=0
  tmp2=0
  l=[]
  for j in range(N):
    if i>>j&1:
      w=pc[j]
      p,c=w[0],w[1]
      tmp+=100*(j+1)*p+c
      tmp2+=p
    else:
      l.append(j)
  if tmp>=G:
    ans=min(ans,tmp2)
  else:
    pc_=copy.copy(pc)
    while tmp<G:
      index=l.pop(-1)
      w=pc_.pop(index)
      p,c=w[0],w[1]
      if 100*(index+1)*p+c+tmp<G:
        tmp+=(100*(index+1)*p+c)
        tmp2+=p
      elif 100*(index+1)*p+tmp<G<=100*(index+1)*p+c+tmp:
        tmp=G
        tmp2+=p
      else:
        val=(G-tmp)//(100*(index+1))
        if (G-tmp)%(100*(index+1))==0:
          tmp2+=val
        else:
          tmp2+=(val+1)
        tmp=G
    ans=min(ans,tmp2)
print(ans)

Submission status: Accepted

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

P.reverse()
C.reverse()
ans = sum(P)
for i in range(2 ** D):
    cnt = 0
    score = 0
    for j, p in enumerate(P):
        if ((i >> j) & 1):
            score += (D - j) * p + C[j]
            cnt += p
    if score >= G:
        ans = min(ans, cnt)
    else:
        for j, p in enumerate(P):
            if ((i >> j) & 1) == 0:
                for k in range(p - 1):
                    score += (D - j)
                    cnt += 1
                    if score >= G:
                        ans = min(ans, cnt)
                        break

print(ans)

Submission status: Accepted

Solution code:
d,g=map(int,input().split())
pc=[list(map(int,input().split())) for i in range(d)]
ans=10**18
for i in range(2**d):
  cnt=0
  res=[]
  x=0
  for j in range(d):
    if i>>j&1:
      cnt+=pc[j][1]+pc[j][0]*(j+1)*100
      x+=pc[j][0]
    else:
      res.append((100*(j+1),pc[j][0]))
  res.sort(reverse=True)
  if cnt>=g:
    ans=min(ans,x)
  elif len(res)>0:
    y=res[0]
    z=0
    while z<y[1] and cnt<g:
      cnt+=y[0]
      z+=1
    if cnt>=g:
      ans=min(ans,x+z)
print(ans)

Submission status: Accepted

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

cs = []
for i in range(D):
    cs.append(100 * (i + 1) * p[i] + c[i])

ans = []
for i in range(2**D):
    score = 0
    n = 0
    han = []
    for j in range(D):
        if i >> j & 1:
            score += cs[j]
            n += p[j]
        else:
            han.append(j)
    if score >= G:
        ans.append(n)
    else:
        for np in reversed(han):
            for j in range(p[np]-1):
                score += 100 * (np + 1)
                n += 1
                if score >= G:
                    ans.append(n)
                    break
            if score >= G:
                break

print(min(ans))

Submission status: Accepted

Solution code:
d,g = map(lambda x: int(x),input().split())
pc_list= []
ans = 0
count = 0
min = 0



for i in range(d):
    p,c = map(lambda x: int(x),input().split())
    pc_list.append([p,c])
    min += p


for j in range(1 << d):
    j_bin = format(j, 'b').zfill(d)
    for k in range(d) :
        ans += int(j_bin[k]) * (100*(1+k)*pc_list[k][0] + pc_list[k][1] )
        if j_bin[k] == '1':
            count += pc_list[k][0]
        else :
            max_re = k
    for l in range(pc_list[max_re][0]):
        if ans >= g :
            break
        ans += 100*(1+max_re)
        count += 1
    if ans >= g and min > count :
        min = count
    ans = 0
    count = 0
print(min)

Submission status: Accepted

Solution code:
d, g = map(int, input().split())
p = []
c = []
for _ in range(d):
    px, cx = map(int, input().split()) 
    p.append(px)
    c.append(cx)

ans = 2<<9

for m in range(1<<d):
    s = 0
    num = 0
    rest_max = -1
    for i in range(d):
        if m>>i & 1:
            s += 100 * (i+1) * p[i] + c[i]
            num += p[i]
        else:
            rest_max = i
    if s < g:
        s1 = 100 * (rest_max + 1)
        need = (g - s + s1 - 1) // s1
        if need >= p[rest_max]:
            continue
        num += need
    ans = min(ans, num)
print(ans)

Submission status: Accepted

Solution code:
D, G = map(int, input().split())
p = [0] * (D + 1)
c = [0] * (D + 1)
for i in range(1, D+1):
    p[i], c[i] = map(int, input().split())
ans = float('inf')


def dfs(i, g):
    global ans
    if i == 0:
        return ans
    cnt = min(g // (100 * i), p[i])
    score = 100 * i * cnt
    if cnt == p[i]:
        score += c[i]
    if g > score:
        cnt += dfs(i - 1, g - score)
    return min(cnt, dfs(i - 1, g))


print(dfs(D, G))

Submission status: Accepted

Solution code:
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())
ans = float('inf')
for bit in range(1 << D):
    score = 0
    cnt = 0
    l = [0] * D
    for j in range(D):
        if (bit >> j) & 1 == 1:
            score += p[j] * 100 * (j + 1) + c[j]
            cnt += p[j]
            l[j] = 1
    if score < G:
        idx = -1
        for k, v in enumerate(l):
            if v == 0:
                idx = k
        if idx != -1:
            p_copy = p.copy()
            while score < G and p_copy[idx] > 0:
                score += (idx + 1) * 100
                cnt += 1
                p_copy[idx] -= 1
    if score < G:
        continue
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
INF = 10**9

def main():
    d,g=map(int,input().split())
    P=[list(map(int,input().split())) for _ in range(d)]
    
    ans=INF
    for bit in range(1<<d):
        score=0
        p=0
        cnt=0
        for i in range(d):
            if (bit>>i)&1:
                score += P[i][0]*100*(i+1)+P[i][1]
                cnt += P[i][0]
            else:
                p = i
       
        if score >= g:
            ans=min(ans,cnt)
        
        else:
            for i in range(P[p][0]-1):
                score += 100*(p+1)
                cnt +=1
                if score >= g:
                    ans=min(ans,cnt)
                    break
    print(ans)
  
if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import re

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

mondai_num = []

for k in range(2**d):

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

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

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

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

Submission status: Accepted

Solution code:
def main():
    D,G =map(int,input().split())
    pc = [list(map(int,input().split())) for i in range(D)]
    max_D = int("1"*D,2)
    res = float("inf")
    for i in range(max_D,-1,-1):
        ansed_num = 0
        point = 0
        now = format(i,"0"+str(D)+"b")
        #print(now)
        for j in range(len(now)):
            if now[j] == "1":
                #print(j+1)
                ansed_num += pc[j][0]
                point += (j+1) * 100 * pc[j][0] + pc[j][1]
        for j in range(len(now)-1,-1,-1):
            if now[j] == "0":
                ansed_num_this = 0
                while point < G and ansed_num_this < pc[j][0]:
                    ansed_num += 1
                    point += (j+1) * 100
                    ansed_num_this += 1
            #print(ansed_num,point)
            if point >= G:
                if ansed_num < res:
                    res = ansed_num
    print(res)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
D,G=map(int,input().split())
pl=[0]*D
cl=[0]*D
for i in range(D):
  pl[i],cl[i]=map(int,input().split())
ans=[]
for bit in range(2**D):
  compl=[]
  count=0
  score=0
  for i in range(D):
    if bit&(1<<i):
      score+=pl[i]*100*(i+1)+cl[i]
      count+=pl[i]
      compl.append(i)
  if score>=G:
    ans.append(count)
  else:
    n=max(set(range(D))-set(compl))
    for i in range(pl[n]):
      score+=100*(n+1)
      count+=1
      if score>=G:
        ans.append(count)
        break
print(min(ans))

Submission status: Accepted

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

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

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

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

    if cnt_v >= g:
        ans.append(cnt)

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

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

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

print(min(ans))

Submission status: Accepted

Solution code:
D,G = list(map(int, input().split()))
P = []
C = []
for i in range(D):
    p,c = list(map(int, input().split()))
    P.append(p)
    C.append(c)
s = {i for i in range(D)}
flag = False
bit = 0
number = []

for bit in range(2**D):
    score = 0
    count = 0
    comp = []
    # print(bit)
    for j in range(D):
        if bit & (1<<j):
            score += P[j] * 100 * (j+1) + C[j]
            count += P[j]
            comp.append(j)
    if score >= G:
        number.append(count)
    else:
        n = max(s-set(comp))
        for k in range(P[n]):
            score += 100 * (n+1)
            count += 1
            if score >= G:
                number.append(count)
                break

print(min(number))