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: Wrong Answer

Solution code:
import math
d, g = map(int, input().split())
p = [0 for _ in range(d+1)]
c = [0 for _ in range(d+1)]
ans = 10000
for i in range(d):
    pi, ci = map(int, input().split())
    p[i+1] = pi
    c[i+1] = ci     
for bit in range ( 1 << d):
    score = 0
    cnt = 0
    tokanai_saidai = 0
    for i in range(d):
        if bit & (1 << i):
            score += p[i+1] * 100 * (i+1) + c[i+1]
            cnt += p[i+1]
        else:
            tokanai_saidai = i + 1
    if score > g:
        if cnt < ans:
            ans = cnt
    else:
        nokori_score = g - score
        if nokori_score < 100 * (tokanai_saidai) * p[tokanai_saidai]:
            cnt += math.ceil(nokori_score / (100 * tokanai_saidai))
            if cnt < ans:
                ans = cnt 
print(ans)

Submission status: Wrong Answer

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

P = []; C = []
for i in range(D):
    pi, ci = map(int, input().split())
    P.append(pi)
    C.append(ci)

max_cnt = sum(P)

def solve(i, score, cnt, nm):
    if i == D:
        if score >= G:
            return cnt
        else:
            add_cnt = (G-score)/((nm+1)*100)
            if add_cnt > P[nm]:
                return max_cnt
            else:
                return cnt + int(add_cnt)
    return min([solve(i+1, score+P[i]*(i+1)*100 + C[i], cnt+P[i], nm), 
                solve(i+1, score, cnt, i)])

a = solve(0, 0, 0, 0)
print(a)

Submission status: Wrong Answer

Solution code:
import math
d,g=map(int,input().split())
pc=[list(map(int,input().split())) for i in range(d)]
ans=10000000000000000000
for i in range(1<<d):
    s=0
    ans_=0
    for j in range(d):
        if (i>>j)&1:
            s+=(pc[j][1]+pc[j][0]*100*(j+1))
            ans_+=pc[j][0]
    #print(s,ans_)
    if s>=g:
        ans=min(ans,ans_)
    else:
        for j in range(d-1,-1,-1):
            if not((i>>j)&1):
                if s+(pc[j][0]*100*(j+1))>=g:
                    h=-((s-g)//(100*(j+1)))
                    s+=(h*100*(j+1))
                    ans_+=h
                else:
                    break
        else:
            ans=min(ans,ans_)
print(ans)
#ansとans_

Submission status: Wrong Answer

Solution code:
import math
d,g=map(int,input().split())
pc=[list(map(int,input().split())) for i in range(d)]
ans=10000000000000000000
for i in range(1<<d):
    s=0
    ans_=0
    for j in range(d):
        if (i>>j)&1:
            s+=(pc[j][1]+pc[j][0]*100*(j+1))
            ans_+=pc[j][0]
    #print(s,ans_)
    if s>=g:
        ans=min(ans,ans_)
    else:
        for j in range(d-1,-1,-1):
            if not((i>>j)&1):
                if s+(pc[j][0]*100*(j+1))>=g:
                    h=math.ceil((g-s)/100/(j+1))
                    s+=(h*100*(j+1))
                    ans_+=h
                else:
                    s+=((pc[j][0]-1)*100*(j+1))
                    ans_+=(pc[j][0]-1)
        else:
            ans=min(ans,ans_)
print(ans)
#ansとans_

Submission status: Wrong Answer

Solution code:
import math
d,g=map(int,input().split())
pc=[list(map(int,input().split())) for i in range(d)]
ans=10000000000000000000
for i in range(1<<d):
    s=0
    ans_=0
    for j in range(d):
        if (i>>j)&1:
            s+=(pc[j][1]+pc[j][0]*100*(j+1))
            ans_+=pc[j][0]
    #print(s,ans_)
    if s>=g:
        ans=min(ans,ans_)
    else:
        for j in range(d-1,-1,-1):
            if not((i>>j)&1):
                if s+(pc[j][0]*100*(j+1))>=g:
                    h=math.ceil((g-s)/100/(j+1))
                    s+=(h*100*(j+1))
                    ans_+=h
                else:
                    break
        else:
            ans=min(ans,ans_)
if ans==10000000000000000000:
    r
print(ans)
#ansとans_

Submission status: Wrong Answer

Solution code:
import math
d,g=map(int,input().split())
pc=[list(map(int,input().split())) for i in range(d)]
ans=10000000000000000000
for i in range(1<<d):
    s=0
    ans_=0
    for j in range(d):
        if (i>>j)&1:
            s+=(pc[j][1]+pc[j][0]*100*(j+1))
            ans_+=pc[j][0]
    #print(s,ans_)
    if s>=g:
        ans=min(ans,ans_)
    else:
        for j in range(d-1,-1,-1):
            if not((i>>j)&1):
                if s+(pc[j][0]*100*(j+1))>=g:
                    h=math.ceil((g-s)/100/(j+1))
                    s+=(h*100*(j+1))
                    ans_+=h
                else:
                    break
        else:
            ans=min(ans,ans_)
print(ans)

Submission status: Wrong Answer

Solution code:
D,G = map(int,input().split())
PC = [list(map(int,input().split())) for _ in range(D)]

def dfs(d,flag,point,count,tmp):
    point += flag * (PC[d-1][1]+PC[d-1][0]*d*100)
    count += flag * (PC[d-1][0])
    if flag == 0:
        tmp = d
    if d == D:
        if point < G:
            r = (G-point)//(tmp*100)
            if r < PC[tmp-1][0]:
                res = count + r
            else:
                res = float("INF")
        else:
            res = count
        return res

    else:
        return min(dfs(d+1,1,point,count,tmp),dfs(d+1,0,point,count,tmp))

print(min(dfs(1,0,0,0,0),dfs(1,1,0,0,0)))

Submission status: Wrong Answer

Solution code:
# 全探索では時計切れする。
# 全問といたときのボーナス点をbit探索して、それと専門と解いていない時の点と比較？

#場合分けをする。
d,g = map(int, input().split())
l = []
for i in range(d):
    l += [list(map(int, input().split()))]

r = []
for i in range(1 << len(l)):
    li = [0 for i in range(len(l))]
    count = 0
    f = 0
    for j in range(len(l)):
#         print(i,j,r)
        if i & 1 << j:
            li[j]= (j + 1) * l[j][0] * 100 +  l[j][1] 
            count += l[j][0]
#             print(li,count)
        if sum(li) >= g:
            f = 1
            break
            
    li0 = [i for i, x in enumerate(li) if x == 0]
    if not len(li0) == 0:
        p = li0[-1]+ 1
        if 0 < (g - sum(li)) < p * 100 * l[p-1][0]:
            count += (g - sum(li)) // (p * 100) 
#             print(count,  (g - sum(li)), p)
            f = 1
    
    if f == 1:
        r +=[count]
# print(r)
print(min(r))

Submission status: Wrong Answer

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

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

m=100000000000000
for i in range(2**d):
    count=0
    count2=0
    for j in range(d):
        if i&(2**j):
            count+=p[j]*(j+1)*100+c[j]
            count2+=p[j]
    for j in reversed(range(d)):
        if not(i&(2**j)):
            for k in range(p[j]):
                if count>=g and count2<m:
                    m=count2
                    break
                count+=(j+1)*100
                count2+=1
            break

print(m)

Submission status: Wrong Answer

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

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

m=100000000000000
for i in range(2**d):
    count=0
    count2=0
    for j in range(d):
        if i&(2**j):
            count+=p[j]*(j+1)*100+c[j]
            count2+=p[j]
    for j in reversed(range(d)):
        if not(i&(2**j)):
            for k in range(p[j]):
                if count>=g and count2<m:
                    m=count2
                    break
                count+=(j+1)*100
                count2+=1
        break

print(m)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 9999999999999
for i in range(1 << d):
    pos = i
    cnt = 0
    total = 0
    last = -1
    for j in range(d):
        if pos % 2 == 1:
            total += comp[j]
            cnt += num[j]
        else:
            last = j
        pos //= 2
    if total >= g:
        ans = min(ans, cnt)
    elif last == -1:
        continue
    else:
        rem = g - total
        if rem <= num[last] * (last + 1) * 100:
            cnt += math.floor(rem / (last + 1) / 100)
            ans = min(ans, cnt)
print(ans)

Submission status: Wrong Answer

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

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

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


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

Submission status: Wrong Answer

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

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

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


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

Submission status: Wrong Answer

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

ans = 1 << 29
t = []
for bit in range(1<<D):
    score = 0
    f = 0
    # フラグが立ってる問題を全完
    for i in range(D):
        if bit & (1<<i):
            score += pc[i][0]*100*(i+1) + pc[i][1]
            f += pc[i][0]
            if score >= G: break
    # 全完した問題以外の中から点数の高い順に解いていく
    nokori = []
    for j in range(D):
        if not (bit & (1<<j)):
            nokori.append(pc[j] + [j+1])
    nokori = list(reversed(nokori))
    for d in nokori:
        for x in range(d[0]):
            if score >= G: break
            score += 100*(d[2])
            f += 1
        if score >= G: break
    print(bin(bit),f)
    ans = min(ans,f)
print(ans)

Submission status: Wrong Answer

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

ans = 1 << 29
t = []
for bit in range(1<<D):
    score = 0
    f = 0
    # フラグが立ってる問題を全完
    for i in range(D):
        if bit & (1<<i):
            score += pc[i][0]*100*(i+1) + pc[i][1]
            f += pc[i][0]
            if score >= G: break
    # 全完した問題以外の中から点数の高い順に解いていく
    nokori = []
    for j in range(D):
        if not (bit & (1<<j)):
            nokori.append(pc[j] + [j+1])
    nokori = list(reversed(nokori))
    for d in nokori:
        for x in range(d[0]):
            score += 100*(d[2])
            f += 1
            if score >= G: break
        if score >= G: break
    ans = min(ans,f)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

def judge(li):
    score = 0
    cnt = 0
    for i in range(len(li)):
        if li[i] == False:
            continue
        score += pc[i][1]
        score += pc[i][0]*(i+1)*(100)
        cnt += pc[i][0]
    return [cnt,score]
    
        
D,G = map(int,input().split())
pc = []
for i in range(D):
    p,c = map(int,input().split())
    pc.append([p,c])
ans = 100000000000000
for i in range(2**D):
    li = [False]*(D)
    for j in range(D):
        if (i>>j)&1:
            li[D-j-1] = True
    a = judge(li)
    j = D-1
    if a[1]<G:
        while True:
            if a[1]>=G or j == -1:
                break
            if li[j] == True:
                j-=1
                continue
            for k in range(pc[j][0]-1):
                a[1] += (j+1)*(100)
                a[0] += 1
                if a[1]>=G:
                    break
            j-=1
    ans = min(ans,a[0])
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

def judge(li):
    score = 0
    cnt = 0
    for i in range(len(li)):
        if li[i] == False:
            continue
        score += pc[i][1]
        score += pc[i][0]*(i+1)*(100)
        cnt += pc[i][0]
    return [cnt,score]
    
        
D,G = map(int,input().split())
pc = []
for i in range(D):
    p,c = map(int,input().split())
    pc.append([p,c])
ans = 100000000
for i in range(2**D):
    li = [False]*(D)
    for j in range(D):
        if (i>>j)&1:
            li[D-j-1] = True
    a = judge(li)
    j = D-1
    if a[1]<G:
        while True:
            if a[1]>=G or j == -2:
                break
            if li[j] == True:
                j-=1
                continue
            for k in range(pc[j][0]-1):
                a[1] += (j+1)*(100)
                a[0] += 1
                if a[1]>=G:
                    break
            j-=1
    ans = min(ans,a[0])
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math

input = sys.stdin.readline


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


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


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


inf = float("inf")


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

    ans = inf
    for bit in range(2 << d):
        c = 0
        score = 0
        for i in range(d):
            if bit & (1 << i):
                c += pc[i][0]
                score += pc[i][0] * 100 * (i + 1) + pc[i][1]

        while score < g:
            for i in reversed(range(d)):
                if bit & (1 << i):
                    continue
                res = math.ceil((g - score) / (100 * (i + 1)))
                if res < pc[i][0]:
                    c += res
                    score += res * 100 * (i + 1)
                    break
                else:
                    c += pc[i][0]
                    score += pc[i][0] * 100 * (i + 1) + pc[i][1]

        ans = min(ans, c)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math

input = sys.stdin.readline


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


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


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


inf = float("inf")


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

    ans = inf
    for bit in range(2 << d):
        c = 0
        score = 0
        for i in range(d):
            if bit & (1 << i):
                c += pc[i][0]
                score += pc[i][0] * 100 * (i + 1) + pc[i][1]

        while score < g:
            for i in reversed(range(d)):
                if bit & (1 << i):
                    continue
                res = math.ceil((g - score) / (100 * (i + 1)))
                if res <= pc[i][0]:
                    c += res
                    score += res * 100 * (i + 1)
                    break
                else:
                    c += pc[i][0]
                    score += pc[i][0] * 100 * (i + 1) + pc[i][1]

        ans = min(ans, c)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

ans = float("inf")

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: Wrong Answer

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

ans = float("inf")

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))+1)
        count += n
        sum += n * use * 100

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

print(ans)

Submission status: Wrong Answer

Solution code:
d,g = map(int,input().split())
l = [0]*d
s = 0
point = 0
a = 0
count = 0
c = 10**100

for i in range(d):
  l[i] = list(map(int,input().split()))
  s += l[i][0]
  
for i in range(2**s):
  for k in range(d):
    for j in range(a,a+l[k][0]):
      if (i >> j)&1:
        count += 1
        point += (k+1)*100
      
    if point == 100*j:
      point += l[k][1]
      
    a = l[k][0]
    
  if point >=g:
    c = min(count,c)
  count = 0
  
print(count)

Submission status: Wrong Answer

Solution code:
def rec(i, g, count, rem):
    global ans
    if i == 0:
        print(g, count, rem)
        # 総得点がGを超えていなければ、remの中の最高配点の問題を解く
        if g < G:
            # 解く問題
            use = max(rem)
            c = min(pc[use-1][0], -(-(G-g) // (use*100)))
            count += c
            g += use*100 * c
            
            
        if g >= G:
            ans = min(ans, count)
            
    else:
        # 全部解かない
        rec(i-1, g, count, rem)
        # 全部解く
        rem[i] = 0
        rec(i-1, g+i*100*pc[i-1][0]+pc[i-1][1], count+pc[i-1][0], rem)
        rem[i] = i

# 入力
D, G = map(int, input().split())
pc = [[int(i) for i in input().split()] for j in range(D)]
# 解いてない問題リスト
rem = [i for i in range(D+1)]
ans = float("inf")

rec(D, 0, 0, rem)

print(ans)

Submission status: Wrong Answer

Solution code:
def rec(i, g, count, rem):
    global ans
    if i == D:
        # 総得点がGを超えていなければ、remの中の最高配点の問題を解く
        if g < G:
            # 解く問題
            use = max(rem)
            c = min(pc[use-1][0], -(-((G-g) // (use*100))))
            count += c
            g += use*100 * c
            
        if g >= G:
            ans = min(ans, count)
    else:
        # 全部解かない
        rec(i+1, g, count, rem)
        # 全部解く
        rec(i+1, g+(i+1)*100*pc[i][0]+pc[i][1], count+pc[i][0], rem-{i+1})

# 入力
D, G = map(int, input().split())
pc = [[int(i) for i in input().split()] for j in range(D)]
# 解いてない問題リスト
rem = set(range(1, D+1))
ans = float("inf")

rec(0, 0, 0, rem)

print(ans)

Submission status: Wrong Answer

Solution code:
def rec(i, g, count, rem):
    global ans
    if i == 0:
        # 総得点がGを超えていなければ、remの中の最高配点の問題を解く
        if g < G:
            # 解く問題
            use = max(rem)
            c = min(pc[use-1][0], -(-((G-g) // (use*100))))
            count += c
            g += use*100 * c
            
        if g >= G:
            ans = min(ans, count)
    else:
        # 全部解かない
        rec(i-1, g, count, rem)
        # 全部解く
        rec(i-1, g+i*100*pc[i-1][0]+pc[i-1][1], count+pc[i-1][0], rem-{i})

# 入力
D, G = map(int, input().split())
pc = [[int(i) for i in input().split()] for j in range(D)]
# 解いてない問題リスト
rem = set(range(1, D+1))
ans = float("inf")

rec(D, 0, 0, rem)

print(ans)

Submission status: Wrong Answer

Solution code:
def rec(i, g, count, rem):
    global ans
    if i == 0:
        
        # 総得点がGを超えていなければ、remの中の最高配点の問題を解く
        if g < G:
            # 解く問題
            use = max(rem)
            c = min(pc[use-1][0], -(-((G-g) // (use*100))))
            count += c
            g += use*100 * c
            
        if g >= G:
            ans = min(ans, count)
    else:
        # 全部解かない
        rec(i-1, g, count, rem)
        # 全部解く
        rem[i] = 0
        rec(i-1, g+i*100*pc[i-1][0]+pc[i-1][1], count+pc[i-1][0], rem)
        rem[i] = i
    
D, G = map(int, input().split())
pc = [[int(i) for i in input().split()] for j in range(D)]
rem = [i for i in range(D+1)]
ans = float("inf")
rec(D, 0, 0, rem)
print(ans)

Submission status: Wrong Answer

Solution code:
def rec(i, g, count, rem):
    global ans
    if i == 0:
        # 総得点がGを超えていなければ、remの中の最高配点の問題を解く
        if g < G:
            # 解く問題
            use = max(rem)
            c = min(pc[use-1][0], -(-((G-g) // (use*100))))
            count += c
            g += use*100 * c
            
        if g >= G:
            # グローバル変数の方がバックトラック
            ans = min(ans, count)
    else:
        # 全部解かない
        rec(i-1, g, count, rem)
        # 全部解く
        rec(i-1, g+i*100*pc[i-1][0]+pc[i-1][1], count+pc[i-1][0], rem-{i})
    
D, G = map(int, input().split())
pc = [[int(i) for i in input().split()] for j in range(D)]
rem = set(range(1, D+1))
ans = float("inf")
rec(D, 0, 0, rem)
print(ans)

Submission status: Wrong Answer

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

def rec(i, g, count, rem):
    if i == 0:
        if g >= G:
            return count
        else:
            c = -(-((G - g) // (max(rem)*100)))
            if c < pc[max(rem)-1][0]:
                plus = count + c
                return plus
            else:
                return float("inf")
            
    # 全部解かない場合
    c1 = rec(i-1, g, count, rem)
    # 全部解く場合
    rem[i] = 0
    c2 = rec(i-1, g+(i*100*pc[i-1][0])+pc[i-1][1], count+pc[i-1][0], rem)
    g -= (i*100*pc[i-1][0])+pc[i-1][1]
    count -= pc[i-1][0]
    rem[i] = i
    return min(c1, c2)

rem = [i for i in range(D+1)]
print(rec(D, 0, 0, rem))

Submission status: Wrong Answer

Solution code:
from itertools import product

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

def cnts(x, goal=g):
    cnt = 0
    for i in range(d-1, -1, -1):
        if x[i] == 1:
            p, c = pc[i]
            if (p-1) * (i+1) * 100 >= goal:
                cnt += goal // ((i+1) * 100)
                return cnt
                
            elif p * (i + 1) * 100 + c >= goal:
                cnt +=  p
                return cnt
            
            else:
                goal -= p * (i + 1) * 100 + c
                cnt += p
                
    return 10 ** 16

ans = 10 ** 16
for x in product(range(2), repeat=d):
    ans = min(ans, cnts(list(x)))
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import product

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

def cnts(x, goal=g):
    cnt = 0
    for i in range(d-1, -1, -1):
        if x[i] == 1:
            p, c = pc[i]
            if (p-1) * (i+1) * 100 >= goal:
                cnt += goal // ((i+1) * 100)
                return cnt
                
            elif p * (i + 1) * 100 + c >= goal:
                cnt +=  p
                return cnt
            
            else:
                goal -= p * (i + 1) * 100 + c
                cnt += p
                
    return 10 ** 12

ans = 10 ** 12
for x in product(range(2), repeat=d):
    ans = min(ans, cnts(list(x)))
print(ans)

Submission status: Wrong Answer

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):
  sum=0
  count=0
  nokori=set(range(1,d+1))
  for i in range(d):
    if bit&(1<<i):
      sum += p[i]*100*(i+1)+c[i]
      count+= p[i]
      nokori.discard(i + 1)
  if sum<g:
    a=g-sum
    num=max(nokori)
    n=min(p[num-1],(a//(num*100)))
    count+=n
    sum+=n*num*100
  if sum>=g:
    ans=min(ans,count)
    
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# i; 調べる問題番号
# score; 総得点
# count; 解答数
# rest; まだ解いてない問題番号
def dfs(i, score, count, rest):
    global ans
    if i == D:
        # Gを満たしていなければrestの中から解く問題を選ぶ
        if score < G:
            p = max(rest)
            n = min(pc[p-1][0], (G-score) // (p*100))
            count += n
            score += n * p * 100
        
        # Gを満たしていれば現在の最小値と比べる
        if score >= G:
            ans = min(ans, count)
    
    else:
        # 総合点、解答数、解かなかった問題を更新
        # i番の問題を解かない場合
        dfs(i + 1, score, count, rest)
        # i番目の問題を解く場合
        score1 = score + pc[i][0]*100*(i+1) + pc[i][1]
        count1 = count + pc[i][0]
        rest1 = rest - {i + 1}
        dfs(i + 1, score1, count1, rest1)

D, G = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(D)]
rest = set(range(1, D+1))

ans = float("inf")

dfs(0, 0, 0, rest)
print(ans)

Submission status: Wrong Answer

Solution code:
d , g = map(int, input().split())
pc = [list(map(int, input().split()))for i in range(d)]
x=[]
y=[0]*d
ac=[0]*d
for i in range(d):
    ac[i]=pc[i][0]*(i+1)*100+pc[i][1]

def dfs(n,m,y,now):
    if now==n:
        z=y.copy()
        x.append(z)
        return
    for i in range(m):
        y[now]=i
        dfs(n,m,y,now+1)
dfs(d,3,y,0)
mi = 1000
for i in x:
    sum = 0
    cost = 0
    stock = []
    sum2 = 0
    cost2 = 0
    for j in range(d):
        if i[j]==1:
            sum+=ac[j]
            cost+=pc[j][0]
            sum2+=ac[j]
            cost2+=pc[j][0]
        if i[j]==2:
            stock+=[(j+1)*100]*pc[j][0]
            sum2+=pc[j][0]*(j+1)*100
            cost2+=pc[j][0]
    if sum2<g:
        continue
    stock.sort()
    if abs(sum2-g)>abs(sum-g):
        while sum<g and stock:
            sum+=stock.pop()
            cost+=1
    else:
        while sum2>g and stock:
            sum2-=stock.pop()
            cost-=1
        cost+=1
    if sum>=g:
        mi=min(mi,cost)

print(mi)

Submission status: Wrong Answer

Solution code:
d,g=map(int,input().split())
A,B=[],[]
for i in range(d):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
ans=float("inf")
for i in range(2**d):
    s,k=0,0
    for j in range(d):
        if (i>>j)&1:
            s+=A[j]*(j+1)*100+B[j]
            k+=A[j]
    if s>=g:
        ans=min(ans,k)  
    else:
        for l in range(d-1,-1,-1):
            if (i>>l)&1==0:
                if s+(l+1)*100*A[l]<g:
                    s+=(l+1)*100*A[l]
                    k+=A[l]
                else:
                    k+=(g-s)//(l+1)//100
                    ans=min(ans,k)
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math

def solve(D: int, G: int, p: "List[int]", c: "List[int]"):
    ans = 1e9
    for bit in range(2 ** D):
        sum = 0
        rest_max = -1
        num = 0

        for i in range(D):
            if bit & 1 << i:
                sum += (i + 1) * 100 * p[i] + c[i]
                num += p[i]
            else:
                rest_max = i
        
        if sum < G:
            remain = G - sum
            s1 = 100 * (rest_max + 1)
            need = math.floor(remain / s1)
            if need >= p[rest_max]:
                continue
            num += need
        ans = min(ans, num)

    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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()