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:
d, g = map(int, input().split())

p = []
c = []
ans = []
cnt = 0
ss = 0
for _ in range(d):
    pp, cc = map(int, input().split())

    p.append(pp)
    c.append(cc)



for x in range(2**d):
    ss = 0
    cnt = 0
    for i in range(d):
        if (x>>i)&1:

            ss += (i+1)*100*p[i] + c[i]
            cnt += p[i]
    print("a",ss)
    if ss>=g:
        ans.append(cnt)

    else:
        print("c")
        for l in range(d)[::-1]:
            print(l)
            print(x>>l)
            if  ((x >> l) & 1):
                continue

            for _ in range(1,p[l]):
                ss += (l+1)*100
                print("b",ss)
                cnt += 1

                if ss>=g:
                    ans.append(cnt)
                    break

print(min(ans))

Submission status: Wrong Answer

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

p = []
c = []
ans = []
cnt = 0
ss = 0
for _ in range(d):
    pp, cc = map(int, input().split())

    p.append(pp)
    c.append(cc)



for x in range(2**d):
    ss = 0
    cnt = 0
    for i in range(d):
        if (x>>i)&1:

            ss += (i+1)*100*p[i] + c[i]
            cnt += p[i]
    print("a",ss)
    if ss>=g:
        ans.append(cnt)

    else:
        print("c")
        for l in range(d)[::-1]:
            print(l)
            print(x>>l)
            if  ((x >> l) & 1):
                continue

            for _ in range(p[l]):
                ss += (l+1)*100
                print("b",ss)
                cnt += 1

                if ss>=g:
                    ans.append(cnt)
                    break

print(min(ans))

Submission status: Wrong Answer

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

p = []
c = []
ans = []
cnt = 0
ss = 0
for _ in range(d):
    pp, cc = map(int, input().split())

    p.append(pp)
    c.append(cc)

for i,pp in enumerate(list(reversed(p))[::-1]):
    for _ in range(1,pp):
        ss += (len(p)-i+1)*100
        cnt += 1
        if ss>=g:
            ans.append(cnt)


for x in range(2**d):
    ss = 0
    cnt = 0
    for i in range(d):
        if (x>>i)&1:

            ss += (i+1)*100*p[i] + c[i]
            cnt += p[i]
    print("a",ss)
    if ss>=g:
        ans.append(cnt)

    else:
        print("c")
        for l in range(d)[::-1]:
            print(l)
            print(x>>l)
            if not ((x >> l) & 1):

                for _ in range(1,p[l]):
                    ss += (l+1)*100
                    print("b",ss)
                    cnt += 1

                    if ss>=g:
                        ans.append(cnt)
                        break

print(min(ans))

Submission status: Wrong Answer

Solution code:
D, G = map(int,input().split())
p = [0]*D
c = [0]*D
ans = 10**9
for i in range(D):
    p[i], c[i] = map(int,input().split())

for j in range(2**D):
    total_score = 0
    solved_problems = 0
    unsolved = []
    for k in range(D):
        if (j>>k)&1:
            total_score += 100*(k+1)*p[k]+c[k]
            solved_problems += p[k]
        else:
            unsolved.append(k)
    #print(unsolved)
    if unsolved:
        unsolved_idx = max(unsolved)
        if 100*(unsolved_idx+1)*(p[unsolved_idx]-1) + total_score < G:
            continue
        for l in range(p[unsolved_idx]):
            if (l+1)*100*(unsolved_idx+1) + total_score > G:
                solved_problems += l+1
                if solved_problems < ans:
                    ans = solved_problems
                break
    else: #all solved
        if solved_problems < ans:
            ans = solved_problems

print(ans)

Submission status: Wrong Answer

Solution code:
D, G = map(int,input().split())
p = [0]*D
c = [0]*D
ans = 10**9
for i in range(D):
    p[i], c[i] = map(int,input().split())

for j in range(2**D):
    total_score = 0
    solved_problems = 0
    unsolved = []
    for k in range(D):
        if (j>>k)&1:
            total_score += 100*(k+1)*p[k]+c[k]
            solved_problems += p[k]
        else:
            unsolved.append(k)
    #print(unsolved)
    if unsolved:
        unsolved_idx = max(unsolved)
        if 100*(unsolved_idx+1)*(p[unsolved_idx]-1) + total_score < G:
            continue
        for l in range(p[unsolved_idx]):
            if (l+1)*100*(unsolved_idx+1) + total_score >= G:
                solved_problems += l+1
                if solved_problems < ans:
                    ans = solved_problems
                break
    else: #all solved
        if solved_problems < ans:
            ans = solved_problems

print(ans)

Submission status: Wrong Answer

Solution code:
D, G = map(int,input().split())
p = [0]*D
c = [0]*D
ans = 10**9
for i in range(D):
    p[i], c[i] = map(int,input().split())

for j in range(2**D):
    total_score = 0
    solved_problems = 0
    unsolved = []
    for k in range(D):
        if (j>>k)&1:
            total_score += 100*(k+1)*p[k]+c[k]
            solved_problems += p[k]
        else:
            unsolved.append(k)
    #print(unsolved)
    if unsolved:
        unsolved_idx = max(unsolved)
        if 100*(unsolved_idx+1)*(p[unsolved_idx]-1) + total_score < G:
            continue
        for l in range(p[unsolved_idx]):
            if (l+1)*100*(unsolved_idx+1) + total_score >= G:
                solved_problems += l
                if solved_problems < ans:
                    ans = solved_problems
                break
    else: #all solved
        if solved_problems < ans:
            ans = solved_problems

print(ans)

Submission status: Wrong Answer

Solution code:
D, G = map(int,input().split())
p = [0]*D
c = [0]*D
ans = 10**9
for i in range(D):
    p[i], c[i] = map(int,input().split())

for j in range(2**D):
    total_score = 0
    solved_problems = 0
    unsolved = []
    for k in range(D):
        if (j>>k)&1:
            total_score += 100*(k+1)*p[k]+c[k]
            solved_problems += p[k]
        else:
            unsolved.append(k)
    #print(unsolved)
    if unsolved:
        unsolved_idx = max(unsolved)
        if 100*(unsolved_idx+1)*(p[unsolved_idx]-1) + total_score < G:
            continue
        for l in range(p[unsolved_idx]):
            if (l+1)*100*(unsolved_idx+1) + total_score > G:
                solved_problems += l
                if solved_problems < ans:
                    ans = solved_problems
                break
    else: #all solved
        if solved_problems < ans:
            ans = solved_problems

print(ans)

Submission status: Wrong Answer

Solution code:
D, G = map(int,input().split())
p = [0]*D
c = [0]*D
ans = 10**9
for i in range(D):
    p[i], c[i] = map(int,input().split())

for j in range(2**D):
    total_score = 0
    solved_problems = 0
    unsolved = []
    for k in range(D):
        if (j>>k)&1:
            total_score += 100*(k+1)*p[k]+c[k]
            solved_problems += p[k]
        else:
            unsolved.append(k)
    #print(unsolved)
    if unsolved:
        unsolved_idx = max(unsolved)
        if 100*(unsolved_idx+1)*(p[unsolved_idx]-1) + total_score < G:
            continue
        for l in range(p[unsolved_idx]):
            if (l+1)*100*(unsolved_idx+1) + total_score > G:
                solved_problems += l
                if solved_problems < ans:
                    ans = solved_problems
                break

print(ans)

Submission status: Wrong Answer

Solution code:
import math

D, G = map(int, input().split())
pn = []
s_max = []
for i in range(1, D+1):
  p, c = map(int, input().split())
  s_max.append(100*i*p+c)
  pn.append(p)

min = 10 ** 9
for i in range(2**(D)):
  count = 0
  p_count = 0
  no_solve = []
  for j in range(D):
    if i>>j&1 == 1:
      count += s_max[j]
      p_count += pn[j]
    else:
      no_solve.append(j)
  if count >= G:
    if min > p_count:
      min = p_count
  else:
    box = math.ceil((G - count) // (100 * (no_solve[-1]+1)))
    if box < pn[no_solve[-1]]:
      p_count += box
      if min > p_count:
        min = p_count
print(min)

Submission status: Wrong Answer

Solution code:
import math

D, G = map(int, input().split())
pn = []
s_max = []
for i in range(1, D+1):
  p, c = map(int, input().split())
  s_max.append(100*i*p+c)
  pn.append(p)

min = 10 ** 9
for i in range(2**(D)):
  count = 0
  p_count = 0
  no_solve = []
  for j in range(D):
    if i>>j&1 == 1:
      count += s_max[j]
      p_count += pn[j]
    else:
      no_solve.append(j)
  if count >= G:
    if min > p_count:
      min = p_count
  else:
    box = math.ceil((G - count) // (100 * (no_solve[-1]+1)))
    if box >= pn[no_solve[-1]]:
      continue
    else:
      p_count += box
      if min > p_count:
        min = p_count
print(min)

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
sys.setrecursionlimit(10**6)
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
YNeos='YNeos'
GYN=['Yes','trumpet']
mo=10**9+7
imp='IMPOSSIBLE'

d,g=LI()
P=[]
for i in range(d):
    p,c=LI()
    P.append((p,c))
P.sort(key=lambda x:x[1])

ans=10*10

for q in range(2**d-1):
    n,t=0,0
    for i in range(d):
        if (1<<i)&q>0:
            t+=P[i][0]*(i+1)*100+P[i][1]
            n+=P[i][0]
    if t>=g:
        ans=min(ans,n)
        continue
    for i in range(d-1,-1,-1):
        if (1<<i)&q==0:
            pt=(i+1)*100
            c=min(P[i][0]-1,(g-t+pt-1)//pt)
            n+=c
            t+=pt*c
            if t<g:
                break
            ans=min(ans,n)
        
print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
sys.setrecursionlimit(10**6)
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
YNeos='YNeos'
GYN=['Yes','trumpet']
mo=10**9+7
imp='IMPOSSIBLE'

d,g=LI()
P=[]
for i in range(d):
    p,c=LI()
    P.append((p,c))
P.sort(key=lambda x:x[1])

ans=10*10

for q in range(2**d-1):
    n,t=0,0
    for i in range(d):
        if (1<<i)&q>0:
            t+=P[i][0]*(i+1)*100+P[i][1]
            n+=P[i][0]
    if t>=g:
        ans=min(ans,n)
        continue
    for i in range(d-1,-1,-1):
        if (1<<i)&q==0:
            pt=(i+1)*100
            c=min(P[i][0]-1,(g-t+pt-1)//pt)
            n+=c
            t+=pt*c
            if t<g:
                continue
            ans=min(ans,n)
        
print(ans)

Submission status: Wrong Answer

Solution code:
import math
D, G = map(int, input().split())
L = [[int(i) for i in input().split()] for j in range(D)]
p = [L[i][0] for i in range(D)]
q = [L[i][1] for i in range(D)]

#for l in L:
#   l.append(i*l[0]*100+l[1])
#   i += 1

M = [L[i][0]*(i+1)*100+L[i][1] for i in range(D)]
lis = []
for i in range(1 << D):
    s = [0, 0]
    for j in range(D):
        if ((i >> j) & 1) == 1:
            s[0] += p[j]
            s[1] += M[j]
    for j in range(D):
        if ((i >> j) & 1) == 0:
            lis.append(s+[j+1])
        else:
            lis.append(s+[0])
#print(lis)
ans = 1010
for l in lis:
    if G <= l[1]:
        ans = min(ans, l[0])
    elif G - l[1] <= l[2] * 100 * (p[l[2]-1]-1):
        ct = math.floor((G-l[1]) / (l[2]*100))
        ans = min(ans, l[0]+ct)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
D, G = map(int, input().split())
L = [[int(i) for i in input().split()] for j in range(D)]
p = [L[i][0] for i in range(D)]
q = [L[i][1] for i in range(D)]

#for l in L:
#   l.append(i*l[0]*100+l[1])
#   i += 1

M = [L[i][0]*(i+1)*100+L[i][1] for i in range(D)]
lis = []
for i in range(1 << D):
    s = [0, 0]
    for j in range(D):
        if ((i >> j) & 1) == 1:
            s[0] += p[j]
            s[1] += M[j]
    for j in range(D):
        if ((i >> j) & 1) == 0:
            lis.append(s+[j+1])

ans = 1010
for l in lis:
    if G <= l[1]:
        ans = min(ans, l[0])
    elif G - l[1] <= l[2] * 100 * (p[l[2]-1]-1):
        ct = math.floor((G-l[1]) / (l[2]*100))
        ans = min(ans, l[0]+ct)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
D, G = map(int, input().split())
L = [[int(i) for i in input().split()] for j in range(D)]
p = [L[i][0] for i in range(D)]
q = [L[i][1] for i in range(D)]

#for l in L:
#   l.append(i*l[0]*100+l[1])
#   i += 1

M = [L[i][0]*(i+1)*100+L[i][1] for i in range(D)]
lis = []
for i in range(1 << D):
    s = [0, 0]
    for j in range(D):
        if ((i >> j) & 1) == 1:
            s[0] += p[j]
            s[1] += M[j]
    for j in range(D):
        if ((i >> j) & 1) == 0:
            lis.append(s+[j+1])
        else:
            lis.append(s+[0])

ans = 1010
for l in lis:
    if G <= l[1]:
        ans = min(ans, l[0])
    elif G - l[1] < l[2] * 100 * p[l[2]-1]:
        ct = math.floor((G-l[1]) / (l[2]*100))
        ans = min(ans, l[0]+ct)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
D, G = map(int, input().split())
L = [[int(i) for i in input().split()] for j in range(D)]
p = [L[i][0] for i in range(D)]
q = [L[i][1] for i in range(D)]

#for l in L:
#   l.append(i*l[0]*100+l[1])
#   i += 1

M = [L[i][0]*(i+1)*100+L[i][1] for i in range(D)]
lis = []
for i in range(1 << D):
    s = [0, 0]
    for j in range(D):
        if ((i >> j) & 1) == 1:
            s[0] += p[j]
            s[1] += M[j]
    for j in range(D):
        if ((i >> j) & 1) == 0:
            lis.append(s+[j+1])
        else:
            lis.append(s+[0])

ans = 1010
for l in lis:
    if G <= l[1]:
        ans = min(ans, l[0])
    elif G - l[1] <= l[2] * 100 * p[l[2]-1]:
        ct = math.floor((G-l[1]) / (l[2]*100))
        ans = min(ans, l[0]+ct)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
d,g=list(map(int,input().split()))
pc=[list(map(int,input().split())) for i in range(d)]
p = np.array([pc[i][0] for i in range(d)])
c = np.array([pc[i][1] for i in range(d)])
ans = 100000000
#コンプ時の得点リスト
allac = np.array([(i+1)*p[i]*100+c[i] for i in range(d)])
#print(allac)
n = 2**d
for i in range(n):
  alltoita = np.array(list(map(int, list(bin(i)[2:].zfill(d)))))
  alltoitenai = np.array((-1)*alltoita+[1]*d)
 # print(alltoita,alltoitenai)
  num = sum(alltoita*p)
  sc = sum(alltoita*allac)
  for j in range(d-1,-1,-1):
  #  print(alltoitenai[j])
    if alltoitenai[j]==1:
      cnt = 0
      while sc<g and cnt<p[j]:
        sc+=(j+1)*100
        cnt+=1
      break
  #print("#",sc)
  if sc>=g:
    ans = min(ans,num+cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
d,g=list(map(int,input().split()))
pc=[list(map(int,input().split())) for i in range(d)]
p = np.array([pc[i][0] for i in range(d)])
ans = 10000000000
scores=np.array([(i+1)*pc[i][0]*100 + pc[i][1] for i in range(d)])
for i in range(2**d):
  op = np.array(list(map(int,list(bin(i)[2:].zfill(d)))))
  sc = sum(op*scores)
  toitenai = (-1)*op+[1]*d
  sumop = sum(op*p)
  for j in range(d-1,-1,-1):
    if toitenai[j]==1:
      tuika = (j+1)*100
      cnt=0
      while sc<g and cnt<pc[j][0]:
        sc+=tuika
        cnt+=1
      break
  if sc >= g:
    ans =min(ans,sumop+cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
d,g=list(map(int,input().split()))
pc=[list(map(int,input().split())) for i in range(d)]
p = np.array([pc[i][0] for i in range(d)])
ans = 100000000
scores=np.array([(i+1)*pc[i][0]*100 + pc[i][1] for i in range(d)])
for i in range(2**d):
  op = np.array(list(map(int,list(bin(i)[2:].zfill(d)))))
  sc = sum(op*scores)
  toitenai = (-1)*op+[1]*d
  sumop = sum(op*p)
  for j in range(d-1,-1,-1):
    if toitenai[j]==1:
      tuika = (j+1)*100
      cnt=0
      while sc<g and cnt<pc[j][0]:
        sc+=tuika
        cnt+=1
      break
  if sc >= g:
    ans =min(ans,sumop+cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
import math,sys

a,b=map(int,input().split())
c=[list(map(int,input().split()))for i in range(a)]
exp_list = [(i,((i+1)*100*one[0]+one[1])/one[0],(i+1)*100*one[0]+one[1],one[0]) for i,one in enumerate(c)]
exp_list = sorted(exp_list, key=lambda x:-x[1])

sum_ = 0
one_flag = False
question_tmp = []
for ref_num,one in enumerate(exp_list):
    if one[2]  == b:
        one_flag = True
        question_tmp.append(one[3])

if one_flag == True:
    print(min(question_tmp))
else:
    for ref_num,one in enumerate(exp_list):
        if one[2] + sum_ >= b:
            break
        else:
            sum_ += one[2]

    question_nun = 0

    for i in range(ref_num):
        question_nun += exp_list[i][3]

    tmp_sum = sum_
    target = b-sum_

    if target == 0:
        print(question_nun)
    else:
        new_exp_list = exp_list[ref_num:]
        min_num = 1000000
        for one in new_exp_list:
            if one[2] < target:
                continue
            else:
                if target//((one[0]+1)*100)>= one[3]:
                    ref_min = one[3]
                else:
                    ref_min = math.ceil(target/(one[0]+1)/100)

                if ref_min < min_num:
                    min_num = ref_min
        print(question_nun+min_num)

Submission status: Wrong Answer

Solution code:
import math

a,b=map(int,input().split())
c=[list(map(int,input().split()))for i in range(a)]
exp_list = [(i,((i+1)*100*one[0]+one[1])/one[0],(i+1)*100*one[0]+one[1],one[0]) for i,one in enumerate(c)]
exp_list = sorted(exp_list, key=lambda x:-x[1])

sum_ = 0
one_flag = False
question_tmp = []
for ref_num,one in enumerate(exp_list):
    if one[2]  == b:
        one_flag = True
        question_tmp.append(one[3])

if one_flag == True:
    print(min(question_tmp))
    exit()
                
        
        
        

for ref_num,one in enumerate(exp_list):
    if one[2] + sum_ >= b:
        break
    else:
        sum_ += one[2]
        
question_nun = 0

for i in range(ref_num):
    question_nun += exp_list[i][3]

tmp_sum = sum_
target = b-sum_

if target == 0:
    print(question_nun)
else:
    new_exp_list = exp_list[ref_num:]
    min_num = 1000000
    for one in new_exp_list:
        if one[2] < target:
            continue
        else:
            if target//((one[0]+1)*100)>= one[3]:
                ref_min = one[3]
            else:
                ref_min = math.ceil(target/(one[0]+1)/100)

            if ref_min < min_num:
                min_num = ref_min
    print(question_nun+min_num)

Submission status: Wrong Answer

Solution code:
import math

a,b=map(int,input().split())
c=[list(map(int,input().split()))for i in range(a)]
exp_list = [(i,((i+1)*100*one[0]+one[1])/one[0],(i+1)*100*one[0]+one[1],one[0]) for i,one in enumerate(c)]
exp_list = sorted(exp_list, key=lambda x:-x[1])

sum_ = 0
for ref_num,one in enumerate(exp_list):
    if one[2] + sum_ >= b:
        break
    else:
        sum_ += one[2]
        
question_nun = 0

for i in range(ref_num):
    question_nun += exp_list[i][3]

tmp_sum = sum_
target = b-sum_

if target == 0:
    print(question_nun)
else:
    new_exp_list = exp_list[ref_num:]
    min_num = 1000000
    for one in new_exp_list:
        if one[2] < target:
            continue
        else:
            if target//((one[0]+1)*100)>= one[3]:
                ref_min = one[3]
            else:
                ref_min = math.ceil(target/(one[0]+1)/100)

            if ref_min < min_num:
                min_num = ref_min
    print(question_nun+min_num)

Submission status: Wrong Answer

Solution code:
import math

a,b=map(int,input().split())
c=[list(map(int,input().split()))for i in range(a)]
exp_list = [(i,((i+1)*100*one[0]+one[1])/one[0],(i+1)*100*one[0]+one[1],one[0]) for i,one in enumerate(c)]
exp_list = sorted(exp_list, key=lambda x:-x[1])

sum_ = 0
for ref_num,one in enumerate(exp_list):
    if one[2] + sum_ >= b:
        break
    else:
        sum_ += one[2]
        
question_nun = 0

for i in range(ref_num):
    question_nun += c[i][0]

tmp_sum = sum_
target = b-sum_

if target == 0:
    print(question_nun)
else:
    new_exp_list = exp_list[ref_num:]
    min_num = 1000000
    for one in new_exp_list:
        if one[2] < target:
            continue
        else:
            if target//((one[0]+1)*100)>= one[3]:
                ref_min = one[3]
            else:
                ref_min = math.ceil(target/(one[0]+1)/100)

            if ref_min < min_num:
                min_num = ref_min
    print(question_nun+min_num)

Submission status: Wrong Answer

Solution code:
import math

a,b=map(int,input().split())
c=[list(map(int,input().split()))for i in range(a)]
exp_list = [(i,((i+1)*100*one[0]+one[1])/one[0],(i+1)*100*one[0]+one[1],one[0]) for i,one in enumerate(c)]
exp_list = sorted(exp_list, key=lambda x:-x[1])

sum_ = 0
for ref_num,one in enumerate(exp_list):
    if one[2] + sum_ >= b:
        break
    else:
        sum_ += one[2]
        
question_nun = 0

for i in range(ref_num):
    question_nun += c[i][0]

tmp_sum = sum_
target = b-sum_

if target == 0:
    print(question_nun)
else:
    new_exp_list = exp_list[ref_num:]
    min_num = 1000000
    for one in new_exp_list:
        if one[2] < target:
            continue
        else:
            if target//((one[0]+1)*100)>= one[3]:
                ref_min = one[3]
            else:
                print(target/(one[0]+1)/100)
                ref_min = math.ceil(target/(one[0]+1)/100)

            if ref_min < min_num:
                min_num = ref_min
    print(question_nun+min_num)

Submission status: Wrong Answer

Solution code:
from itertools import *

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

P = [None]*D
C = [None]*D

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

products = product(range(2), repeat=D)

ans = float("inf")

for prod in products :
    prod = list(prod)
    
    A = []
    
    cost = 0
    score = 0
    
    for i in range(len(prod)) :
        if prod[i] == 1 :
            A.append(i)
            cost += P[i]
            score += (i+1)*100*P[i]+C[i]
    
    if score < G :
        for i in range(len(prod)-1,-1,-1) :
            if prod[i] == 1 :
                continue
            
            if score + (i+1)*100*P[i] >= G :
                cost += (G-score)//((i+1)*100) + ((G-score) % ((i+1)*100) != 0)
                break
            
            else :
                cost += P[i]
                score += (i+1)*100*P[i]+C[i]
    
    ans = min(ans, cost)

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
A = S
if S == T:
  print('Yes')
else:
  eq = False
  for i in range(len(S)):
    A = A[-1] + A[0:-1]
    if A == T:
      eq = True
      break
  if eq:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

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

ans = 10 ** 7
for i in range(2 ** D):
    bit = format(i, 'b').zfill(D)
    count = 0
    score = 0
    # ボーナスの分を加算
    for index in range(len(bit)):
        if bit[index] == '1':
            score += 100 * (i + 1) * inputs[index][0] + inputs[index][1]
            count += inputs[index][0]
    if G <= score:
        ans = min(ans, count)
        continue
    
    for index in range(len(bit)-1, -1, -1):
        if bit[index] == '0':
            if G - score < 100 * (index + 1) * (inputs[index][0] - 1):
                count += (G - score) // (100 * (index + 1)) + (1 if (G - score) % (100 * (index + 1)) != 0 else 0)
                ans = min(ans, count)
                break
            else:
                score += 100 * (index + 1) * (inputs[index][0] - 1)
                count += inputs[index][0] - 1

print(ans)

Submission status: Wrong Answer

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

ans = 10 ** 9
for i in range(2**d -1):
  ch = bin(i)[2:]
  ch = ch.zfill(d)
  tmpsum = 0
  cnt = 0
  for j in range(d):
    if ch[j] == "1":
      tmpsum += li[j][0]*100*(j+1) + li[j][1]
      cnt += li[j][0]
  if tmpsum >= g:
    ans = min(ans,cnt)
  else:
    ind = d-ch.rfind("0")-1
    if tmpsum + (li[ind][0]-1)*100*(ind+1) >= g:
      ans = min(ans,cnt+(g-tmpsum-1)//(100*(ind+1))+1)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
d,g=map(int,input().split())
p=[]
c=[]
count=0
for i in range(d):
    pi,ci=map(int,input().split())
    p.append(pi)
    c.append(ci)
e=[]
for i in range(d):
    x=p[i]*(i+1)*100+c[i]
    y=x/p[i]
    e.append([y,x,i,p[i]])
e.sort(reverse=True)
for i in range(d):
    if g>=e[0][1]:
        count+=p[e[0][2]]
        g=g-e[0][1]
        aa=e.pop(0)
        #print(aa)
    else:
        break
if g==0:
    print(count)
    sys.exit()
e.sort(key=lambda x:x[3],reverse=True)
print(count+math.ceil(g//((e[0][2]+1)*100)))

Submission status: Wrong Answer

Solution code:
import math
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a)]
d=[0 for i in range(a)]
for i in range(a):
  d[i]=(c[i][0]*(i+1)*100+c[i][1])
e=[0 for i in range(a)]
f=100000000
def s(e,d,c,i):
  g=0
  h=0
  e[i]=c[i][0]
  for j in range(a):
    if e[j]!=0:
      g+=d[j]
    if e[j]==0:
      h=j
  gh=c[h][0]
  global b
  global f
  if b<=g:
    f=min(f,sum(e))
  elif b<=g+(h+1)*100*(gh-1):
    hh=math.floor((b-g)/((h+1)*100))
    f=min(f,sum(e)+hh)
  if i!=a-1:
    s(e,d,c,i+1)
  g=0
  h=0
  e[i]=0
  for j in range(a):
    if e[j]!=0:
      g+=d[j]
    if e[j]==0:
      h=j
  gh=c[h][0]
  global b
  global f
  if b<=g:
    f=min(f,sum(e))
  elif b<=g+(h+1)*100*(gh-1):
    hh=math.floor((b-g)/((h+1)*100))
    f=min(f,sum(e)+hh)
  if i!=a-1:
    s(e,d,c,i+1)
  else:
    return

s(e,d,c,0)
print(f)

Submission status: Wrong Answer

Solution code:
import math
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a)]
d=[0 for i in range(a)]
for i in range(a):
  d[i]=(c[i][0]*(i+1)*100+c[i][1])
e=[0 for i in range(a)]
f=100000000
def s(e,d,c,i):
  g=0
  h=0
  e[i]=c[i][0]
  for j in range(a):
    if e[j]!=0:
      g+=d[j]
    if e[j]==0:
      h=j
  gh=c[h][0]
  global b
  global f
  if b<=g:
    f=min(f,sum(e))
  elif b<=g+(h+1)*100*(gh-1):
    hh=math.floor((b-g)/((h+1)*100))
    f=min(f,sum(e)+hh)
  if i!=a-1:
    s(e,d,c,i+1)
  g=0
  h=0
  e[i]=0
  for j in range(a):
    if e[j]!=0:
      g+=d[j]
    if e[j]==0:
      h=j
  gh=c[h][0]
  global b
  global f
  if b<=g:
    f=min(f,sum(e))
  elif b<=g+(h+1)*100*(gh-1):
    hh=math.floor((b-g)/((h+1)*100))
    f=min(f,sum(e)+hh)
  if i==a-1:
    return
  else:
    s(e,d,c,i+1)

s(e,d,c,0)
print(f)

Submission status: Wrong Answer

Solution code:
import math
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a)]
d=[0 for i in range(a)]
for i in range(a):
  d[i]=(c[i][0]*(i+1)*100+c[i][1])
e=[0 for i in range(a)]
f=100000000
def s(e,d,c,i):
  g=0
  h=0
  e[i]=c[i][0]
  for j in range(a):
    if e[j]!=0:
      g+=d[j]
    if e[j]==0:
      h=j
  gh=c[h][0]
  global b
  global f
  if b<=g:
    f=min(f,sum(e))
  elif b<=g+(h+1)*100*(gh-1):
    hh=math.floor((b-g)/((h+1)*100))
    f=min(f,sum(e)+hh)
  if i==a-1:
    return
  else:
    s(e,d,c,i+1)
  g=0
  h=0
  e[i]=0
  for j in range(a):
    if e[j]!=0:
      g+=d[j]
    if e[j]==0:
      h=j
  gh=c[h][0]
  global b
  global f
  if b<=g:
    f=min(f,sum(e))
  elif b<=g+(h+1)*100*(gh-1):
    hh=math.floor((b-g)/((h+1)*100))
    f=min(f,sum(e)+hh)
  if i==a-1:
    return
  else:
    s(e,d,c,i+1)

s(e,d,c,0)
print(f)

Submission status: Wrong Answer

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

for i in range(D):
    b = [[List[i][0], List[i][0]*(i+1)*100+List[i][1]] for i in range(D)]
    
m = 10**9
for j in range(1, 2**D):
    cnt = 0
    score = 0
    flg = 0
    for k in range(D):
        if ((j>>k)&1):
            cnt+=b[k][0]
            score+=b[k][1]
            flg+=1
            used = k
        else:
            unused = k
    if G<=score:
        if flg==1:
            cnt = -(-G//((used+1)*100))
            if cnt<m:
                m = cnt
        else:
            if cnt<m:
                m = cnt
                
    else: 
        diff = G-score
        offset = -(-diff//((unused+1)*100))
        cnt += offset
        if offset<List[unused][0]:
            if cnt<m:
                m = cnt
print(m)