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:
D,G=map(int,input().split())
import math
ans=10**9
prob=[]
for i in range(D):
  p,c=map(int,input().split())
  prob.append((p,c))
for i in range(2**D):
  i=format(i-1,'b').rjust(D,'0')
  alll=[]
  notall=[]
  for j in range(D):
    if i[j]=='1':
      alll.append(j)
    else:
      notall.append(j)
  if notall!=[]:
    maxnotall=notall[-1]  
  point=0
  tans=0
  for i in alll:
    point+=100*(i+1)*prob[i][0]+prob[i][1]
    tans+=prob[i][0]
  if point>=G:
    ans=min(tans,ans)
  if point<G:
    if 100*(maxnotall+1)*(prob[maxnotall][0]-1)>=G-point:
      tans+=math.ceil((G-point)/(100*(maxnotall+1)))
      ans=min(tans,ans)
    else:
      ans=ans

if ans==10**9:
  ans=0
  for i in range(D):
    ans+=prob[i][0]
print(ans)

Submission status: Accepted

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

ans = 100*11
for i in range(2**d):
    sum = 0
    cnt = 0
    a = []
    for j in range(d):
        if (i >> j) & 1 == 1:
            sum += (j+1)*100*pc[j][0] + pc[j][1]
            cnt += pc[j][0]
            a.append(j)
    if sum < g:
        for j in range(d):
            if d-j-1 not in a:
                for k in range(pc[d-j-1][0]):
                    if sum >= g:
                        break
                    sum += (d-j)*100
                    cnt += 1
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:
import math

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

ans = float("inf")

for bit in range(1 << D):
    cnt = 0
    sum = 0
    pids = set(range(D))

    for i in range(D):
        if bit & (1 << i):
            sum += pc[i][0] * (i + 1) * 100 + pc[i][1]
            cnt += pc[i][0]
            pids.discard(i)

    if sum < G:
        pid = max(pids)
        n = min(pc[pid][0], math.ceil((G - sum) / ((pid + 1) * 100)))
        cnt += n
        sum += n * (pid + 1) * 100
        
    if sum >= G:
        ans = min(ans, cnt)

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 = 100000000000000

for bit in range(1 << d):
    count = 0
    sum = 0
    nokori = set(range(1, d + 1))

    for i in range(d):
        if bit & (1 << i):
            sum += pc[i][0] * (i + 1) * 100 + pc[i][1]
            count += pc[i][0]
            nokori.discard(i + 1)

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

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

print(ans)

Submission status: Accepted

Solution code:
import itertools
d,g=map(int,input().split())
p=[]
c=[]
for i in range(d):
    p1,c1=map(int,input().split())
    p.append(p1)
    c.append(c1//100)
n=list(itertools.permutations(list(range(1,d+1))))
ans=1024
g//=100
for i in range(len(n)):
    cnt=g
    cnt2=0
    for j in range(d):
        num3=n[i][j]
        num4=num3*p[num3-1]
        if num4>=cnt:
            cnt2+=((cnt-1)//num3)+1
            break
        elif num4+c[num3-1]>=cnt:
            cnt2+=p[num3-1]
            break
        else:
            cnt-=num4+c[num3-1]
            cnt2+=p[num3-1]
    ans=min(ans,cnt2)
print(ans)

Submission status: Accepted

Solution code:
D, G = map(int, input().split()) #D: 問題数, G: 目標点
PC = [list(map(int, input().split())) for i in range(D)]

ans = float("inf")

for i in range(2**D):
    tmp = 0
    cnt = 0
    dic = set(range(1, D+1))
    for j in range(D):
        if (i >> j)&1: #その問題は全て解く
            tmp += PC[j][0] * (j+1) * 100 + PC[j][1]
            cnt += PC[j][0]
            dic.discard(j+1)

    if tmp < G:
        t = max(dic)
        p, c = PC[t-1][0], PC[t-1][1]
        if t*100*p+c+tmp >= G:
            while p:
                tmp += t*100
                cnt += 1
                if tmp >= G:
                    break
            ans = min(ans, cnt)
    else:
        ans = min(ans, cnt)
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 = float('inf')

for i in range(1<<d):
  count = 0
  sum = 0
  nokori = set(range(1, d+1))
  
  for j in range(d):
    if i & (1 << j):
      sum += pc[j][0]*(j+1)*100 + pc[j][1]
      count += pc[j][0]
      nokori.discard(j+1)
      
  if sum<g:
    use = max(nokori)
    n = min(pc[use-1][0], -(-(g-sum)//(use*100)))
    count += n
    sum += n*use*100
    
  if sum>=g:
    ans = min(ans, count)
    
print(ans)

Submission status: Accepted

Solution code:
import math
d,g=map(int,input().split())
p=[list(map(int,input().split())) for _ in range(d)]
ans=sum([i[0] for i in p])
for i in range(2**d-1):
    bit=bin(i)[2:].zfill(d)
    c,s,a=0,0,0
    for j in range(d):
        if bit[j]=='1':
            c+=p[j][0]
            s+=p[j][1]+100*(j+1)*p[j][0]
        else:
            a=max(a,j)
    short=g-s
    pc=max(math.ceil(short/((a+1)*100)),0)
    if pc<p[a][0]:
        ans=min(c+pc,ans)
print(ans)

Submission status: Accepted

Solution code:
d,G = map(int,input().split())
g = G//100
plist = [list() for _ in range(d)]
pp = []
pe = []
for i in range(d):
    p,C = map(int,input().split())
    c = C//100
    pp += [p]
    if p==1:
        pe += [i]
    plist[i] += [i+1]*(p-1)
    plist[i] += [i+1+c]

poli = [list() for _ in range(d)]
for i in range(d):
    poli[i] += [plist[i][0]]
    for j in range(pp[i]-1):
        poli[i] += [poli[i][j]+plist[i][j+1]]

import math
numli = []
for i in range(2**d):
    kari = 0
    nkanli = []
    karimon = 0
    for j in range(d):
        if (i>>j)&1 == 1:
            kari += poli[j][-1]
            karimon += pp[j]
        else:
            nkanli +=[j]
    if kari>=g:
        numli += [karimon]
    else:
        if nkanli == []:
            continue
        else:
            for k in range(len(nkanli)-1,-1,-1):
                if nkanli[k] in pe:
                    continue
                else:
                    if kari + poli[nkanli[k]][-2]>=g:
                        karimon += math.ceil((g-kari)/(nkanli[k]+1))
                        numli += [karimon]
                        break
                    else:
                        break
    #print(kari,nkanli,karimon)
#print(numli)
print(min(numli))

Submission status: Accepted

Solution code:
import itertools
D, G = map(int, input().split())
ans = 10000000000
list_pro = [list(map(int, input().split())) for _ in range(D)]
for ptr in itertools.product([0,1], repeat=D):
  cnt_pro = 0
  res = 0
  for i,k in enumerate(ptr):
    if k == 1:
      cnt_pro += list_pro[i][0]
      res += 100 * (i+1) * list_pro[i][0] + list_pro[i][1]
  if res < G:
    for j, l in enumerate(reversed(ptr)):
      if l == 0:
        for _ in range(list_pro[D-1-j][0]):
          if res >= G:
            break
          res += 100 * (D-j)
          cnt_pro += 1      
  if res >= G:
    ans = min(ans, cnt_pro)
print(ans)

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


d,g = list(map(int, input().split()))
pc = [None]*d
for i in range(d):
    pc[i] = tuple(map(int, input().split()))
pc = pc[::-1]
ans = float("inf")
for b in range(1<<d):
    nokori = g
    val = 0
    for i in range(d):
        if b>>i&1:
            nokori -= (pc[i][0]*100*(d-i) + pc[i][1])
            val += pc[i][0]
    
    if nokori>0:
        for j in range(d):
            if b>>j&1:
                continue
            if pc[j][0]*100*(j+1)>=nokori:
                tmp = nokori//(100*(d-j)) + int(nokori%(100*(d-j))>0)
                val += tmp
                nokori -= tmp*(100*(d-j))                    
            else:
                nokori -= (pc[j][0]*100*(d-j) + pc[j][1])
                val += pc[j][0]
            if nokori<=0:
                break
    ans = min(ans, val)
print(ans)

Submission status: Accepted

Solution code:
import sys
from itertools import *
from math import *
input=sys.stdin.readline
D, G = map(int, input().split())
probs = [list(map(int, input().split())) for _ in range(D)]
G2 = G
seq = tuple(range(D))
x=[]
for i in range(0,D+1):
    l=combinations(seq,i)
    for j in l:
        x.append(j)
x=tuple(x)
#print(x)
infty=100000
#print(x)
ans = infty
for cand in x:
    cnt = 0
    G=G2
    l=[0]*D
    for ind in cand:
        probpoint = (ind + 1) * 100
        G=G-(probpoint * probs[ind][0]+probs[ind][1])
        cnt = cnt + probs[ind][0]
        l[ind]=1
    #print(l,G,cnt)
    for i in range(D-1,-1,-1):
        if G<=0:
            break
        elif l[i]==0:
            probpoint = (i + 1) * 100
            num=ceil(G/probpoint)
            if num<probs[i][0]:
                G=G-num*probpoint
                cnt=cnt+num
            #print(cnt)
            break
    if G<=0:
        ans=min(ans,cnt)
print(ans)

Submission status: Accepted

Solution code:
d,g = map(int, input().split())
ps = []
cs = []
for i in range(d):
    p,c = map(int, input().split())
    ps.append(p)
    cs.append(c)
INF = 1 << 50
dp = [INF]*110000
dp[0] = 0
for k,(p,c) in enumerate(zip(ps,cs)):
    tmp = dp[:]
    for i in range(p+1):
        for j in range(g//100+1):
            if dp[j] == INF:continue
            if i < p:
                tmp[j+(k+1)*i] = min(dp[j+(k+1)*i], dp[j]+i)
            else:
                tmp[j+(k+1)*i+c//100] = min(dp[j+(k+1)*i+c//100], dp[j]+i)
    dp = tmp[:]
print(min(dp[g//100:]))

Submission status: Accepted

Solution code:
from itertools import product
import math
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(D)]

ans = []

for lst in product([0, 1], repeat=D):
    temp = 0
    cnt = 0
    max0 = -1
    p = 0
    for i, j in enumerate(lst):
        temp += (pc[i][0] * 100 * (i+1) + pc[i][1]) * j
        cnt += pc[i][0] * j
        if j == 0 and max0 < i: max0 = i
    if temp < G and max0 != -1:
        p = math.ceil((G - temp)/(100 * (max0 + 1)))
        if p < pc[max0][0]:
            cnt += p
            temp += p * 100 * (max0 + 1)
    if temp >= G: ans.append(cnt)

print(min(ans))

Submission status: Accepted

Solution code:
import sys,math,collections,itertools,copy
input = sys.stdin.readline

D,G=list(map(int,input().split()))
score = []
maxScore = []
maxS = []
for d in range(D):
    p,c=map(int,input().split())
    tmp = [(d+1)*100]*p
    tmp[-1]+=c
    score.append(tmp)
    maxScore.append(sum(tmp))
    maxS.append([p,sum(tmp)])

#-最大いくつの問題セットを必要とするか-#
maxScore.sort()
tmp = 0
for idx,mS in enumerate(maxScore):
    tmp += mS
    if tmp >= G:
        max_num = idx+1
        break
#-足し上げる-#
choice = set(range(1,D+1))
ans = float('inf')
for ch in itertools.permutations(choice,max_num):
    times = 0
    total = 0
    flag = 0
    for ci in ch:
        if total + maxS[ci-1][1] <G:
            total += maxS[ci-1][1]
            times += maxS[ci-1][0]
        else:
            for sc in score[ci-1]:
                total += sc
                times += 1
                if total >= G:
                    ans = min(ans,times)
                    falg = 1
                    break
    if flag ==1:
        break
print(ans)

Submission status: Accepted

Solution code:
import sys,math,collections,itertools,copy
input = sys.stdin.readline

D,G=list(map(int,input().split()))
score = []
maxScore = []
cos_per = []
maxS = []
for d in range(D):
    p,c=map(int,input().split())
    tmp = [(d+1)*100]*p
    tmp[-1]+=c
    score.append(tmp)
    maxScore.append(sum(tmp))
    maxS.append([p,sum(tmp)])
    #cos_per.append([d+1,sum(tmp)/p])
    cos_per.append([d+1,d+1])
#-最大いくつの問題セットを必要とするか-#
maxScore.sort()
tmp = 0
for idx,mS in enumerate(maxScore):
    tmp += mS
    if tmp >= G:
        max_num = idx+1
        break
#-最小でいくつの問題セットを必要とするか-#
tmp = 0
j=0
for i in range(len(maxScore)-1,-1,-1):
    j+=1
    tmp += maxScore[i]
    if tmp >= G:
        min_num = j
        break
#-最小-2個はスコアが高いものを入れてよし-#
#cos_per.sort(key = lambda x:-x[1])
choice = set(range(1,D+1))
#choiceList = []
#for i in range(0,min_num-3):
 #   choiceList+=score[cos_per[i][0]-1]
 #   choice.discard(cos_per[i][0])
 #   max_num -=1
 
#-足し上げる-#

ans = float('inf')
for ch in itertools.permutations(choice,max_num):
    times = 0
    total = 0
    flag = 0
    for ci in ch:
        if total + maxS[ci-1][1] <G:
            total += maxS[ci-1][1]
            times += maxS[ci-1][0]
        else:
            for sc in score[ci-1]:
                total += sc
                times += 1
                if total >= G:
                    ans = min(ans,times)
                    falg = 1
                    break
    if flag ==1:
        break
print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    D, G = read_values()
    P = [0] * D
    C = [0] * D
    for i in range(D):
        P[i], C[i] = read_values()
        
    dp = [0] * (sum(P) + 1)
    for i in range(2 ** D):
        A = [0 if (i >> k) & 1 else P[k] - 1 for k in range(D)]
        r = sum(P[k] if (i >> k) & 1 else 0 for k in range(D))
        t = sum(C[k] + P[k] * (k + 1) * 100 if (i >> k) & 1 else 0 for k in range(D))
        dp[r] = max(dp[r], t)
        for j in range(D - 1, - 1, -1):
            for k in range(1, A[j] + 1):
                r += 1
                t += (j + 1) * 100
                dp[r] = max(dp[r], t)
    for i in range(len(dp) - 1):
        dp[i + 1] = max(dp[i +1], dp[i])
    # print(dp)
    print(bisect.bisect_left(dp, G))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def dfs(i, sum, count, nokori):
    global ans
    if i == d:
        if sum < g:
            use = max(nokori)

            n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
            count += n
            sum += n * use * 100

        if sum >= g:
            ans = min(ans, count)
            
    else:
        dfs(i+1, sum, count, nokori)
        dfs(i+1, sum + pc[i][0] * (i+1) * 100 + pc[i][1], count + pc[i][0], nokori - {i + 1})


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

ans = float("inf")

dfs(0, 0, 0, set(range(1, d+1)))
print(ans)

Submission status: Accepted

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

point = point[::-1]

ans = float("inf")
for bit in range(1<<d):
  total=0
  cnt=0
  for i in range(d):
    if (bit>>i)&1:
      total += (100*(d-i)*point[i][0]+point[i][1])
      cnt += point[i][0]
  if total >= g:
    ans = min(ans,cnt)
    continue
  for j in range(d):
    if (bit>>j)&1 == False:
      for k in range(point[j][0]):
        total += 100*(d-j)
        cnt += 1
        if total >= g:
          ans=min(ans,cnt)
          break
      break
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    D, G = NMI()
    pc = [NLI() for _ in range(D)]
    ans = 1000
    
    bit_len = D
    for i in range(2**bit_len):
        ls = [0 for _ in range(bit_len)]
        for j in range(bit_len):
            if (i >> j) & 1:
                ls[j] = 1
        
        point = 0
        solved = 0
        half_way = ""
        
        for n in range(D):
            if ls[n] == 1:
                solved += pc[n][0]
                point += pc[n][0]*100*(n+1) +pc[n][1]
            else:
                half_way = n
        
        if G > point:
            if half_way != "":
                remain = int(math.ceil((G-point)/((half_way+1)*100)))
                if remain <pc[half_way][0]:
                    solved += remain
                    ans = min(ans,solved)
        else:
            ans = min(ans,solved)
        
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    D, G, *PC = map(int, read().split())
    P = PC[::2]
    C = PC[1::2]

    ans = INF
    for mask in range(1 << D):
        problems = score = 0
        for i in range(D):
            if mask & (1 << i):
                problems += P[i]
                score += 100 * (i + 1) * P[i] + C[i]
            else:
                idx_max = i

        if score >= G:
            if ans > problems:
                ans = problems
            continue

        if score + 100 * (idx_max + 1) * (P[idx_max] - 1) >= G:
            problems += (G - score + 100 * (idx_max + 1) - 1) // (100 * (idx_max + 1))
            if ans > problems:
                ans = problems

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    D, G, *PC = map(int, read().split())
    P = PC[::2]
    C = PC[1::2]

    ans = INF
    for mask in range(1 << D):
        problems = score = 0
        available = [False] * D
        for i in range(D):
            if mask & (1 << i):
                problems += P[i]
                score += 100 * (i + 1) * P[i] + C[i]
            else:
                available[i] = True

        if score >= G:
            if ans > problems:
                ans = problems
            continue

        for i in range(D - 1, -1, -1):
            if not available[i]:
                continue
            if score + 100 * (i + 1) * P[i] + C[i] < G:
                problems += P[i]
                score += 100 * (i + 1) * P[i] + C[i]
            else:
                n = (G - score + 100 * (i + 1) - 1) // (100 * (i + 1))
                problems += n
                score += 100 * (i + 1) * n
                break

        if score >= G and ans > problems:
            ans = problems

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
D,G=map(int,input().split())
G/=100
P=[]
C=[]
for _ in range(D):
    x,y=map(int,input().split())
    P.append(x)
    C.append(y//100)

ans=10**9
for x in range(2**D):
    cost=0
    value=0
    for i in range(D):
        if (x>>i)%2==1:
            value += P[i]*(i+1) + C[i]
            cost += P[i]
    for i in range(D-1,-1,-1):
        if value >= G:
            break
        elif (x>>i)%2==0:
            for _ in range(P[i]-1):
                value += i+1
                cost += 1
                if value>=G:
                    break
    if value>=G:
        ans=min(ans,cost)
print(ans)

Submission status: Accepted

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

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

n = len(a)

min_val = sum(p)
for i in range(1 << n):
    score = 0
    val = 0
    k = -1
    for j in range(n):
        if i >> j & 1:
            score += a[j]
            val += p[j]
        else:
            k = j
    r = g - score
    if r > 0:
        if r >= a[k]:
            continue
        else:
            l = math.ceil(r / ((k + 1) * 100))
            if l >= p[k]:
                continue
            val += l
    min_val = min(min_val, val)
print(min_val)

Submission status: Accepted

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

import math
# スペース区切りの整数の入力
d, g = map(int, input().split())
#配列の入力
data = [list(map(int, input().split())) for _ in range(d)]
sn=1000

for i in range(2**d):
    ts = [False]*d
    score = 0
    tmp_sn = 0
    flg = True
    for j in range(d):
        if (i>>j)&1:
            ts[j] = True
            score += data[j][0]*100*(j+1)+data[j][1]
            tmp_sn += data[j][0]


    if score < g:
        for k in reversed(range(len(ts))):
            if  ts[k] == False:
                need = g - score
                s1 = (k+1) * 100
                nnum = math.ceil(need / s1)
                if nnum < data[k][0]:
                    tmp_sn += nnum
                    break
                else:
                    flg = False
                    break

    if flg == True and sn > tmp_sn:
        sn = tmp_sn

print(sn)

Submission status: Accepted

Solution code:
from collections import defaultdict

def main():
    D, G = map(int, input().split())
    problem = []
    for _ in range(D):
        p, c = map(int, input().split())
        problem.append([p,c])
    ans = float('inf')
    for i in range(2**D):
        all_solve = []
        others = []
        score = 0
        cnt = 0
        for j in range(D):
            if (i >> j) & 1:
                all_solve.append(j)
                cnt += problem[j][0]
                score += 100 * (j+1) * problem[j][0] + problem[j][1]
            else:
                others.append(j)
        if score >= G:
            ans = min(cnt,ans)
            continue

        others.sort(reverse=True)
        for k in others:
            for m in range(problem[k][0]):
                score += 100*(k+1)
                cnt += 1
                if score >= G:
                    ans = min(ans, cnt)
                    break
            else:
                score += problem[k][1]
                if score >= G:
                    ans = min(ans, cnt)
            if score >= G:
                break
        
        if score >= G:
            ans = min(ans, cnt)

        
    print(ans)    

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
D, G = map(int, input().split())
data = [list(map(int, input().split())) for i in range(D)]
ps, cs = zip(*data)
clear_cnt = D
min_prb = 1000
for i in range(1 << D):
    result = 0
    num_prb = 0
    not_selected_list = list()
    for j in range(D):
        if (i >> j & 1):
            result += ps[j] * 100 * (j+1) + cs[j]
            num_prb += ps[j]
        else:
            not_selected_list.append(j)
    if result < G:
        not_selected = max(not_selected_list)
        add_num_prb = min(ps[not_selected], -(-(G - result)//(100*(not_selected+1))) )
        num_prb += add_num_prb
        result += add_num_prb * (not_selected+1) * 100
    if result >= G:
        min_prb = min(min_prb, num_prb)
print(int(min_prb))

Submission status: Accepted

Solution code:
def min2(x,y):
    return x if x < y else y

from math import ceil
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 = float("inf")
for bit in range(1<<D):
    temp = 0
    cnt = 0
    for i in range(D):
        if (bit>>i)&1:
            temp += 100*(i+1)*P[i]+C[i]
            cnt += P[i]
    if temp >= G:
        res = min2(res, cnt)
        continue
    for i in reversed(range(D)):
        if not (bit>>i)&1:
            k = ceil((G-temp)/(100*(i+1)))
            if k >= P[i]:
                temp += 100*(i+1)*(P[i]-1)
                cnt += P[i]-1
            else:
                cnt += k
                res = min2(res, cnt)
                break
print(res)

Submission status: Accepted

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

ans = float('inf')

for i in range(1 << d):
  count = 0
  sum = 0
  nokori = set(range(1, d+1))
  
  for j in range(d):
    if i & (1<<j):
      sum += pc[j][0] * (j+1) * 100 + pc[j][1]
      count += pc[j][0]
      nokori.discard(j+1)
      
  if sum < g:
    use = max(nokori)
    n = min(pc[use-1][0], -(-(g-sum)//(use*100)))
    count += n
    sum += n*use*100
    
  if sum >= g:
    ans = min(ans, count)

print(ans)

Submission status: Accepted

Solution code:
from itertools import product
max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

D,G = map(int,input().split())

pc = [tuple(map(int,input().split())) for _ in range(D)]
pc = [(p,c,100*i) for i,(p,c) in enumerate(pc, start=1)]
res = sum(p for p,c,k in pc)
for choice in product((True,False),repeat=D):
    t = sum(c+p*k for (p,c,k),f in zip(pc,choice) if f)
    steps = sum(p for (p,c,k),f in zip(pc,choice) if f)

    if t >= G:
        res = min2(res,steps)
        continue

    for (p,c,k),f in zip(reversed(pc), reversed(choice)):
        if not f:
            break

    if p*k+t >= G:
        steps += (G-t-1)//k + 1
        res = min2(res,steps)

print(res)

Submission status: Accepted

Solution code:
import itertools as itr

D,G=map(int, input().split())
p=[list(map(int, input().split()))  for _ in range(D)]
b=list(itr.product(range(2),repeat=D))

ans=float('INF')

for i in range(len(b)):
    temp=0
    pnt=0
    for j in range(D):
        if b[i][j]==1:
            temp+=p[j][0]
            pnt+=(j+1)*100*p[j][0]
            pnt+=p[j][1]

    if pnt>=G:
        ans=min(ans,temp)
        
    else:
        for j in range(D):
            if b[i][-j-1]==0:
                for k in range(p[-j-1][0]-1):
                    temp+=1
                    pnt+=(D-j)*100
                    if pnt>=G:  
                        ans=min(ans,temp)
                        break
                break
                
print(int(ans))

Submission status: Accepted

Solution code:
[D,G],*li = [list(map(int,i.split())) for i in open(0)]

ans = float('inf')

def dfs(i,ten,num,p):
    global ans
    if i==D:
        if ten >= G:
            ans = min(ans,num)
        else:
            for q in p:
                for r in range(li[q][0]):
                    ten += (q+1)*100
                    num += 1
                    if r==li[q][0]:
                        ten += li[q][1]
                    if ten >= G:
                        ans = min(ans,num)
                        break
                else:continue
                break
    else:
        dfs(i+1,ten+(i+1)*100*li[i][0]+li[i][1],num+li[i][0],p)
        dfs(i+1,ten,num,[i]+p)
dfs(0,0,0,[])
print(ans)

Submission status: Accepted

Solution code:
def ForBaseConvert(Roop,MaxD,Base):
    if all(type(TT) is int for TT in [Roop,MaxD,Base]):
        if Base>=2 and MaxD>=1:
            ConvertN = []
            while Roop>0:
                ConvertN.append(Roop%Base)
                Roop = Roop//Base

            BaseConv = [0]*(MaxD-len(ConvertN))+ConvertN[::-1]
            BaseSInd = [[] for TB in range(0,Base)]
            for TB in range(0,Base):
                BaseSInd[TB] = [SInd for SInd,SNum in enumerate(BaseConv) if SNum==TB]
            return BaseConv,BaseSInd
        else:
            return []
    else:
        return []

import math
D,G = (int(T) for T in input().split())
PCList = [[] for TD in range(0,D)]
MINSolve = 1000
for TD in range(0,D):
    PCList[TD] = [int(T) for T in input().split()]

for Roop in range(0,2**D):
    Failed = False
    BaseConv,BaseSInd = ForBaseConvert(Roop,D,2)
    Solve = 0
    Point = 0
    for TD in range(0,D):
        if BaseConv[TD]==1:
            Solve += PCList[TD][0]
            Point += (100*(TD+1)*PCList[TD][0])+PCList[TD][1]
    
    if len(BaseSInd[0])>0:
        Add = BaseSInd[0][-1]
        Ned = math.ceil(max(G-Point,0)/(100*(Add+1)))
        if Ned<=(PCList[Add][0]-1):
            Solve += Ned
            Point += 100*(Add+1)*Ned
     
    if Point>=G and Solve<MINSolve:
        MINSolve = Solve
print(MINSolve)

Submission status: Accepted

Solution code:
d,g=map(int,input().split())
g//=100
A=[]
for i in range(d):
    p,c=map(int,input().split())
    c//=100
    A.append([i+1, p, c])
ans=float("inf")
# print(A)
for bit in range(1<<d):
    now=0 ; mon=0
    for i in range(d):
        if bit>>i &1:
            now+=A[i][0]*A[i][1]+A[i][2]
            mon+=A[i][1]
    # print(bit,now,mon)
    if now>=g:
        ans=min(ans,mon)
        continue
        
    for i in range(d-1,-1,-1):
        if bit>>i &1==0:
            for j in range(A[i][1]): #余りに何問とくか
                now+=A[i][0] ; mon+=1
                if now>=g:
                    ans=min(ans,mon)
                    continue
                else:
                    continue
print(ans)