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())
A=[]
a=0
b=0
for i in range(d):
  a,b=map(int, input().split())
  A.append([a,b])


minp=0#現時点での問題数の最小値（最初は全問題数の合計にしておく）
for i in range(d):
  minp+=A[i][0]



for i in range(2**d):
  sco=0 #点数
  pro=0 #問題数
  bini=bin(i)[2:].zfill(d)
  #print(bini)
  for j in range(d):
    if bini[j]=="1" : #iの2進数で1の問題セットは完全に解く
      pro+=A[j][0]
      sco+=A[j][0]*100*(j+1)+A[j][1]
  if sco<g : #このとき、解いてない中でスコア最大の問題を何問か解く必要がある
    #print(bini)
    totyuu=-1
    j=0
    while totyuu==-1 :
      if bini[d-j-1]=="0" :
        totyuu=d-j-1
      j+=1
    #print(totyuu)
    #print(g-sco)
    if g-sco<=(A[totyuu][0]-1)*100*(totyuu+1):
      pro=pro+(g-sco-1)//(100*(totyuu+1))+1
    else:
      pro=999

  #print(str(pro)+" "+bini)

  if pro<minp :
    minp=pro

print(minp)

Submission status: Wrong Answer

Solution code:
D,G = map(int, input().split())
prob_num = []
bonus = []
comp_pt = []
for i in range(D):
    p,b = map(int, input().split())
    prob_num.append(p)
    bonus.append(b)
    comp_pt.append(100*(i+1)*p+b)

def dfs(hascomp:str, target:int, prob:int, depth:int) -> int:
    if target <= 0:
        #print(hascomp, depth, prob)
        return prob
    
    elif depth == D:
        for i in range(D-1,-1,-1):
            if hascomp[i] == "n":
                if target <= 100*(i+1)*(prob_num[i]-1):
                    prob += (target//(100*(i+1)))+bool(target%(100*(i+1)))
                    print(hascomp, depth, prob)
                    return prob
                
                else:
                    prob += (prob_num[i]-1)
                    target -= 100*(i+1)*(prob_num[i]-1)
                    
        if target > 0:
            #print(hascomp, depth, prob)
            return 10**5
        
    else:
        new_tar = target-comp_pt[depth]
        new_prob = prob + prob_num[depth]
        return min(dfs(hascomp+"y",new_tar, new_prob, depth+1),
                   dfs(hascomp+"n",target, prob, depth+1))
        

ans = dfs("",G,0,0)
print(ans)

Submission status: Wrong Answer

Solution code:
D,G = map(int, input().split())
p = [0] * D
c = [0] * D
j = [0] * D
p_min = 1000
r = 1
for i in range(D):
  p[i],c[i] = map(int, input().split())
  r = r*p[i]
for k in range(r):
  sum = 0
  p_sum = 0
  for i in range(D):
    sum = sum + j[i]*(i+1)*100
    p_sum = p_sum + j[i]
    if j[i] == p[i]:
      sum = sum + c[i]

  if sum >= G and p_sum < p_min:
    p_min = p_sum

  i = 0
  def saiki(i):
    if j[i] != a[i]:
      j[i] = j[i]+1
    else:
      j[i] = 0
      saiki(i+1)

print(p_min)

Submission status: Wrong Answer

Solution code:
from itertools import permutations, product
from math import ceil, floor

D, G = [int(elem) for elem in input().split(' ')]
point_info_list = [[int(elem) for elem in input().split()] for _ in range(D)]
assert len(point_info_list) == D
assert len(point_info_list[0]) == 2

# time complexity: O(D!)
""" min_num = float('inf')
for perm in permutations(range(D)):
    current_point = 0
    current_num = 0
    for point in perm:
        if (G - current_point) - (point + 1) * 100 * point_info_list[point][0] <= 0:
            current_num += ceil((G - current_point) / ((point + 1) * 100))
            break
        elif (G - current_point) - (point + 1) * 100 * point_info_list[point][0] - point_info_list[point][1] <= 0:
            current_num += point_info_list[point][0]
            break
        else:
            current_point += (point + 1) * 100 * point_info_list[point][0] + point_info_list[point][1]
            current_num += point_info_list[point][0]
    min_num = min(current_num, min_num)

print(min_num)
 """

# time complexity: O(D2^D)
min_num = float('inf')
for mask in product([False, True], repeat=D):
    chosen_indices = [i for i, chosen in enumerate(mask) if chosen]
    current_point = 0
    current_num_solved = 0
    for chosen_index in chosen_indices:
        point = (chosen_index + 1) * 100
        num_problems = point_info_list[chosen_index][0]
        bonus = point_info_list[chosen_index][1]
        current_point += point * num_problems + bonus
        current_num_solved += num_problems

    try:
        max_indice_of_the_others = max(set(range(D)) - set(chosen_indices))
    except ValueError:
        continue
    point = (max_indice_of_the_others + 1) * 100
    num_problems = point_info_list[max_indice_of_the_others][0]
    if (G - current_point) - point * num_problems > 0:
        continue
    elif G - current_point < 0:
        min_num = min(min_num, current_num_solved)
    else:
        current_num_solved += ceil((G - current_point) / point)
        min_num = min(min_num, current_num_solved)
print(min_num)

Submission status: Wrong Answer

Solution code:
import random
import bisect
import math

option = 0     # 0:PSO 1:CFA 2:CFArank
max_or_min = 0 # 0:minimize 1:maxmize

iter=1

N = 50 #粒子の数
T = 1000 #世代数(ループの回数)
maximum=1
minimum=0

dimension, limit = [int(i) for i in input().split()]

pi = [0 for i in range(dimension)]
ci = [0 for i in range(dimension)]
       
for i in range(dimension):
    pi[i], ci[i] = [int(i) for i in input().split()]

tot = [pi[i] * (i+1) * 100 + ci[i] for i in range(dimension)]
#print(pi)
#print(ci)
#print(tot)


#--------粒　子　群　最　適　化------------------------------

#評価関数
def criterion(x):
    
    z = sum([pi[i] * x[i] for i in range(dimension)])
    z2 = sum([tot[i] * x[i] for i in range(dimension)])
    k = -1
    for i in range(dimension):
      if x[dimension -1 -i] == 0:
        k = dimension -1 -i
        break
    if k != -1:
      for i in range(pi[k]):
        if limit > z2:
          z += 1
          z2 +=  (k+1) * 100
        else:
          break

    if limit > z2:
        z = 10000
    return z

#粒子の位置の更新を行う関数
def update_position(x, v, x_min, x_max):
#    new_x = [x_min[i] if x[i]+ v[i] < x_min[i] else x_max[i] if x[i]+ v[i] > x_max[i] else x[i]+ v[i] for i in range(dimension)]
    new_x = [1 if random.uniform(0, 1)< 1/(1+math.e**(-v[i])) else 0 for i in range(dimension)]
    return new_x

#粒子の速度の更新を行う関数
def update_velocity(x, v, p, g, w, ro_max=1.0, c1=2.00, c2=0.75):
    #パラメーターroはランダムに与える
    phi=c1+c2
    K=2/abs(2-phi-(phi*phi-4*phi)**0.5)
    
    #粒子速度の更新を行う
    if option!=0:
        new_v = [K * ( w * v[i] + c1 * random.uniform(0, ro_max) * (p[i] - x[i]) + c2 * random.uniform(0, ro_max) * (g[i] - x[i]) ) for i in range(dimension)]
    else:
        new_v = [w * v[i] + c1 * random.uniform(0, ro_max) * (p[i] - x[i]) + c2 * random.uniform(0, ro_max) * (g[i] - x[i]) for i in range(dimension)]

    return new_v

def main():
    w = 1.0
    w_best, w_worst = 1.25, 0.25
    x_min = [minimum for i in range(dimension)]
    x_max = [maximum for i in range(dimension)]
    
    #粒子位置, 速度, パーソナルベスト, グローバルベストの初期化を行う
    ps = [[random.randint(x_min[j], x_max[j]) for j in range(dimension)] for i in range(N)]
    vs = [[0.0 for j in range(dimension)] for i in range(N)]

    personal_best_positions = ps[:] 
    personal_best_scores = [criterion(p) for p in ps]

    if max_or_min == 1:
        best_particle = personal_best_scores.index(max(personal_best_scores))
    elif max_or_min == 0:
        best_particle = personal_best_scores.index(min(personal_best_scores))
    global_best_position = personal_best_positions[best_particle][:]

    for t in range(T):
        for n in range(N):
            x = ps[n][:]
            v = vs[n][:]
            p = personal_best_positions[n][:]

            if option>=2:
                best_list = sorted(personal_best_positions)
                mu = bisect.bisect_left( best_list, p ) + 1
                w = w_best - mu * (w_best - w_worst) / (N - 1)


            #粒子の位置の更新を行う
            new_x = update_position(x, v, x_min, x_max)
            ps[n] = new_x[:]

            #粒子の速度の更新を行う
            new_v = update_velocity(new_x, v, p, global_best_position, w)
            vs[n] = new_v[:]

            #評価値を求め, パーソナルベストの更新を行う
            score = criterion(new_x)

            if max_or_min == 1:
                if score > personal_best_scores[n]:
                    personal_best_scores[n] = score
                    personal_best_positions[n] = new_x[:]
            elif max_or_min == 0:
                if score < personal_best_scores[n]:
                    personal_best_scores[n] = score
                    personal_best_positions[n] = new_x[:]

        #グローバルベストの更新を行う
        if max_or_min == 1:
            best_particle = personal_best_scores.index(max(personal_best_scores))
            global_best_position = personal_best_positions[best_particle][:]

        elif max_or_min == 0:
            best_particle = personal_best_scores.index(min(personal_best_scores))
            global_best_position = personal_best_positions[best_particle][:]
                     
        f.write(str(max(personal_best_scores))+"\n")
    #最適解
    if max_or_min == 1:
        return max(personal_best_scores)
    elif max_or_min == 0:
        return min(personal_best_scores)

#--------------------------------------------------------------
with open('test_'+ str(option)+".txt", 'w') as f:
    
  if max_or_min == 1:
    best=-float("inf")
    for i in range(iter):
        best=max(best, main())

  elif max_or_min == 0:
    best=float("inf")
    for i in range(iter):
        best=min(best, main())

print(best)

Submission status: Wrong Answer

Solution code:
class Solution:
    def __init__(self):
        self.count = 0

    def check(self):
        n, target = map(int, input().split())
        array = [[0] * 3 for i in range(n)]

        for i in range(n):
            a, b = map(int, input().split())
            full_score = a * (i + 1) * 100 + b
            array[i] = a, b, (i + 1) * 100

        while target > 0:
            sorted(array, key=lambda x: (x[2] * x[0] + x[1]) / x[0] if x[2] * x[0] + x[1] <= target else x[2])
            a, b, c = array.pop()

            if a * c + b <= target:
                self.count += a
                target -= a * c + b
            else:
                self.count += target // c
                target = 0

        return self.count


print(Solution().check())

Submission status: Wrong Answer

Solution code:
d,g=map(int,input().split())
pc=[list(map(int,input().split()))for _ in [0]*d]
r=1000
for k in range(2**d):
    s=''.join((['0']*d+list(str(bin(k))[2:]))[-d:])
    vs=[(pc[i][0]*100*(i+1)+pc[i][1])*int(s[i]) for i in range(d)]
    v=sum(vs)
    tr=sum([pc[i][0]*int(s[i]) for i in range(d)])
    if v>=g:
        r=min(r,tr)
    else:
        rest_max=d-s[::-1].find('0')-1
        if rest_max<d and v+(pc[rest_max][0]-1)*100*(rest_max+1)>=g and (g-v)//((rest_max+1)*100)<pc[rest_max][0]:
            r=min(r,tr+(g-v)//((rest_max+1)*100))
print(r)

Submission status: Wrong Answer

Solution code:
D,G= map(int,input().split())
pc=[]
for i in range(D):
  p,c= map(int,input().split())
  pc.append([p,c])
i=D
minN=100000
while i>0:
  #t=pc[i][0]*100*(i+1)+pc[i][1]
  t=pc[i-1][0]*100*(i)+pc[i-1][1]
  if t>=G:
    
    n=pc[i-1][0]
    minN=min(n,minN)
    while n-1>0:
      t1=(n-1)*100*(i)
      if t1>G:
        n=n-1
        continue
      else:
        minN=min(minN,n+1)
      n=n-1
    
  i=i-1
print(minN)

Submission status: Wrong Answer

Solution code:
d,g=map(int,input().split())
pc=[list(map(int,input().split()))for _ in [0]*d]
r=1000
for k in range(2**d):
    s=''.join((['0']*d+list(str(bin(k))[2:]))[-d:])
    vs=[(pc[i][0]*100*(i+1)+pc[i][1])*int(s[i]) for i in range(d)]
    v=sum(vs)
    tr=sum([pc[i][0]*int(s[i]) for i in range(d)])
    if v>=g:r=min(r,tr)
    else:
        f=False
        for j in reversed(range(d)):
            if s[j]=='1':continue
            t=(g-v)//((j+1)*100)
            if t<pc[j][0]:tr+=t;f=True
            break
        if f:r=min(r,tr)
print(r)

Submission status: Wrong Answer

Solution code:
d,g=map(int,input().split())
pc=[list(map(int,input().split()))for _ in [0]*d]
r=1000
for k in range(2**d):
    s=''.join((['0']*d+list(str(bin(k))[2:]))[-d:])
    vs=[(pc[i][0]*100*(i+1)+pc[i][1])*int(s[i]) for i in range(d)]
    v=sum(vs)
    tr=sum([pc[i][0]*int(s[i]) for i in range(d)])
    f=False
    for j in reversed(range(d)):
        if s[j]=='1':continue
        t=max((g-v)//((j+1)*100),0)
        if t<pc[j][0]:tr+=t;f=True
        break
        '''
        if 
            tr+=t
            #print(i,r,v,j,tr,t,vs,[pc[i][0]*int(s[i]) for i in range(d)])
            break
        else:
            v+=(j+1)*100*(pc[j][0]-1)
            tr+=pc[j][0]-1
        '''
    if f:r=min(r,tr)
print(r)

Submission status: Wrong Answer

Solution code:
import itertools
import math

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

p = {}
c = {}
s = {}
for i in range(1, D + 1):
    pi, ci = map(int, input().split())
    score = 100 * i * pi + ci
    s[i] = score
    p[i] = pi
    c[i] = ci


def complete(pset):
    score = 0
    solved = 0
    comped = set()
    for i, b in zip(range(1, D + 1), pset):
        if b:
            score += s[i]
            solved += p[i]
            comped.add(i)
    leftset = set(list(range(1, D + 1))) - comped
    return score, solved, leftset


def left(norm, leftset):
    if norm <= 0:
        return 0
    if len(leftset) == 0:
        return 0
    i = max(leftset)
    res = int(math.floor(norm / (100 * i)))
    if res < p[i]:
        return res
    return float("inf")


ans = float("inf")
for pset in itertools.product((True, False), repeat=D):
    score, solved, leftset = complete(pset)
    solved += left(G - score, leftset)
    ans = min(ans, solved)

print(ans)

Submission status: Wrong Answer

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

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

def Calc(score, num):
    temp = list(filter(lambda x: x[1] < num+1, score))
    if temp == []:
        return score[-1][0] * num
    else:
        cand = []
        if len(score) == 1:
            cand.append(temp[0][0]*temp[0][1] + temp[0][2])
        else:
            copy_score = score.copy()
            for t in temp:
                temp_score = score.copy()
                del temp_score[temp_score.index(t)]
                del copy_score[copy_score.index(t)]
                cand.append(t[0]*t[1] + t[2] + Calc(temp_score, num - t[1]))
            if len(copy_score) > 0:
                cand.append(copy_score[-1][0] * num)
        return max(cand)

a, b = 1, q_sum+1
while (b-a) > 1:
    print(a, b)
    if Calc(Score, (b+a) // 2) >= G:
        b = (b+a) // 2
    else:
        a = (b+a) // 2
if Calc(Score, a) >= G:
    print(a)
else:
    print(b)

Submission status: Wrong Answer

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

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

def Calc(score, num):
    temp = list(filter(lambda x: x[1] < num+1, score))
    if temp == []:
        return score[-1][0] * num
    else:
        cand = []
        if len(score) == 1:
            cand.append(temp[0][0]*temp[0][1] + temp[0][2])
        else:
            copy_score = score.copy()
            for t in temp:
                temp_score = score.copy()
                del temp_score[temp_score.index(t)]
                del copy_score[copy_score.index(t)]
                cand.append(t[0]*t[1] + t[2] + Calc(temp_score, num - t[1]))
            if len(copy_score) > 0:
                cand.append(copy_score[-1][0] * num)
        return max(cand)

a, b = 1, q_sum+1
while (b-a) > 2:
    if Calc(Score, (b+a) // 2) >= G:
        b = (b+a) // 2
    else:
        a = (b+a) // 2
if Calc(Score, a) >= G:
    print(a)
else:
    print(b)

Submission status: Wrong Answer

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

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

def Calc(score, num):
    temp = list(filter(lambda x: x[1] < num+1, score))
    if temp == []:
        return score[-1][0] * num
    else:
        cand = []
        if len(score) == 1:
            cand.append(temp[0][0]*temp[0][1] + temp[0][2])
        else:
            copy_score = score.copy()
            for t in temp:
                temp_score = score.copy()
                del temp_score[temp_score.index(t)]
                del copy_score[copy_score.index(t)]
                cand.append(t[0]*t[1] + t[2] + Calc(temp_score, num - t[1]))
            if len(copy_score) > 0:
                cand.append(copy_score[-1][0] * num)
        return max(cand)

a, b = 1, q_sum+1
while (b-a) > 2:
    print(a,b)
    if Calc(Score, (b+a) // 2) >= G:
        b = (b+a) // 2
    else:
        a = (b+a) // 2
if Calc(Score, a) >= G:
    print(a)
else:
    print(b)

Submission status: Wrong Answer

Solution code:
D, G = map(int, input().split())
dic = {}
for i in range(1, D+1):
  p, c = map(int, input().split())
  comp = p * i * 100 + c
  ratio = comp/p
  dic[i] = (ratio, comp, i, p, c)
arr = sorted(dic.values(), key=lambda x: x[0], reverse=True)

point = 0
unused = list(range(1, D+1))
count = 0
for a in arr:
  if point + a[1] < G:
    point += a[1]
    unused.remove(a[2])
    count += a[3]
  else:
    break

re = [dic[i] for i in unused]

while True:
  left = G - point
  if point >= G or len(re) == 0:
    print(count)
    exit()
  p_min = sorted(re, key=lambda x: x[3], reverse=False)[0]
  p = p_min[3]
  i_max = sorted(re, key=lambda x: x[2], reverse=True)[0]
  i = int(p_min[1]/(i_max[2]*100)) + 1 if int(p_min[1]/(i_max[2]*100)) + 1 < i_max[3] else i_max[3]
  if i > p:
    count += p
    point += p_min[1]
    re.remove(p_min)
  else:
    count += i
    point += i * 100* i_max[2]
    re.remove(i_max)

Submission status: Wrong Answer

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

tmp = input()
d = int(tmp.split(" ")[0])
g = int(tmp.split(" ")[1])
 
p=[]
c=[]
a=[]
b=[]

for i in range(d):
    tmp=input()
    p.append(int(tmp.split(" ")[0]))
    c.append(int(tmp.split(" ")[1]))
    a.append(int((i+1)*100))
    b.append(int(a[i]*p[i]+c[i]))

x=g
y=int(0)
k=int(0)

for i in range(d):
    x=x-b[d-i-1]
    k=k+p[d-i-1]
    if x<0:
        y=d-i-1
        x=x+b[d-i-1]
        k=k-p[d-i-1]
        break
z=x
m=c[y]
l=int(0)
while x>0:
    l=l+1
    x=x-a[y]
    m=m-1
    if m==0:
        x=x-c[y]

for i in range(y):
    if z<b[i]:
        if l>p[i]:
            l=p[i]

print(k+l)

Submission status: Wrong Answer

Solution code:
import numpy as np

D, G = input().split()
D = int(D)
G = int(G)
pn = []
cn = []
for i in range(D):
    p, c = input().split()
    pn.append(int(p))
    cn.append(int(c))
    
dp = np.zeros([D, max(pn)])
score = 0

score += 100
for i in range(pn[0]):
    if(i == (pn[0]-1)):
        dp[0][i] = score*(i+1) + cn[0]
    else:
        dp[0][i] = score*(i+1)

for j in range(1, D):
    score += 100
    for i in range(pn[j]):
        if(i == (pn[j]-1)):
            only = score*(i+1) + cn[j]
        else:
            only = score*(i+1)
        if(i == 0):
            ahead = 0
        else:
            ahead = dp[j][i-1]
        under = dp[j-1][i]
        dp[j][i] = max([only, ahead, under])
        
for j in range(max(pn)):
    if(G <= max(dp[:,j])):
        print(j+1)
        break

Submission status: Wrong Answer

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

tmp = input()
d = int(tmp.split(" ")[0])
g = int(tmp.split(" ")[1])
 
p=[]
c=[]
a=[]
b=[]

for i in range(d):
    tmp=input()
    p.append(int(tmp.split(" ")[0]))
    c.append(int(tmp.split(" ")[1]))
    a.append(int((i+1)*100))
    b.append(int(a[i]*p[i]+c[i]))

x=g
y=int(0)
k=int(0)

for i in range(d):
    x=x-b[d-i-1]
    k=k+p[d-i-1]
    if x<0:
        y=d-i-1
        x=x+b[d-i-1]
        k=k-p[d-i-1]
        break

m=c[y]
l=int(0)
while x>0:
    l=l+1
    x=x-a[y]
    m=m-1
    if m==0:
        x=x-c[y]

for i in range(y):
    if x<b[i]:
        if l>p[i]:
            l=p[i]

print(k+l)

Submission status: Wrong Answer

Solution code:
import itertools
import math

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

P = set()
p = {}
c = {}
s = {}
for i in range(1, D + 1):
    pi, ci = map(int, input().split())
    score = 100 * i * pi + ci
    P.add(i)
    s[i] = score
    p[i] = pi
    c[i] = ci


def complete(pset):
    score = 0
    solved = 0
    comped = set()
    i = 1
    for b in pset:
        if b:
            score += s[i]
            solved += p[i]
            comped.add(i)
        i += 1
    return score, solved, comped


def left(norm, comped):
    if norm <= 0:
        return 0
    for i in sorted(list(P - comped), reverse=True):
        res = int(math.floor(norm / (100 * i)))
        if res < p[i]:
            return res
    return float("inf")


ans = float("inf")
for pset in itertools.product((True, False), repeat=D):
    score, solved, comped = complete(pset)
    solved += left(G - score, comped)
    ans = min(ans, solved)

print(ans)

Submission status: Wrong Answer

Solution code:

D,G = 5,25000
prob_num = [20,40,50,30,1]
comp = [1000,1000,1000,1000,1000,1000]

comp_point = []
for i in range(D):
    comp_point.append((100*(i+1)*prob_num[i]+comp[i]))


res = G
ans = 0
while res>0:
    req_prob = []
    temp_min = []
    temp_value = []
    for i in range(D):
        if prob_num[i] == 0:
            req_prob.append(10000000)
        elif res>=100*(i+1)*prob_num[i]:
            req_prob.append(prob_num[i])
        else:
            req_prob.append((res//(100*(i+1))) + bool(res%(100*(i+1))))
            
    for i in range(D):
        temp_min.append(min(res,comp_point[i]))
        
    for i in range(D):
        temp_value.append(temp_min[i]/req_prob[i])
        
    choice = temp_value.index(max(temp_value))
    
    ans += req_prob[choice]
    if 100*(choice+1)*req_prob[choice] < comp_point[choice]:

        res -= 100*(choice+1)*req_prob[choice]
    else:
        res -= comp_point[choice]
    prob_num[choice] -= req_prob[choice]
    
#    print(ans,res)
    
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())

arr = [[0 for i in range(2)] for j in range(D)]

for i in range(D):
    arr[i][0] = i
    arr[i][1] = (100*(i+1)*p[i] + c[i])/p[i]
arr.sort(key=lambda x:x[1])

sum = 0
count = 0
for i in range(D):
    for j in range(p[arr[i][0]]):
        sum += 100*(arr[i][0]+1)
        if j == p[arr[i][0]]:
            sum += c[i]
        if sum > G:
            print(count)
        count += 1

Submission status: Wrong Answer

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

tmp = input()
d = int(tmp.split(" ")[0])
g = int(tmp.split(" ")[1])
 
p=[]
c=[]
a=[]
b=[]

for i in range(d):
    tmp=input()
    p.append(int(tmp.split(" ")[0]))
    c.append(int(tmp.split(" ")[1]))
    a.append(int((i+1)*100))
    b.append(int(a[i]*p[i]+c[i]))

x=g
y=int(0)
k=int(0)

for i in range(d):
    x=x-b[d-i-1]
    k=k+p[d-i-1]
    print(k)
    if x<0:
        y=d-i-1
        x=x+b[d-i-1]
        k=k-p[d-i-1]
        break

m=c[y]
l=int(0)
while x>0:
    l=l+1
    x=x-a[y]
    m=m-1
    if m==0:
        x=x-c[y]

for i in range(y):
    if x<b[i]:
        if l>p[i]:
            l=p[i]

print(k+l)

Submission status: Wrong Answer

Solution code:

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


A = G/100
max = 1

for d_i in d:
    max += d_i[0]

dp = [[[0, 0] for i in range(max+1)] for j in range(D)]

okcount = [max for j in range(D)]

for i in range(D):
    for j in range(max):

        dp[i][j + 1][0] = dp[i][j][0]
        dp[i][j + 1][1] = dp[i][j][1]

        if dp[i][j][1] + 1 < d[i][0]:
            if dp[i][j][0] + i + 1 > dp[i][j+1][0]:
                dp[i][j + 1][0] += i + 1
                dp[i][j + 1][1] += 1
        elif dp[i][j][1] + 1 == d[i][0]:
            if dp[i][j][0] + i + 1 + d[i][1]//100 > dp[i][j + 1][0]:
                dp[i][j + 1][0] += i + 1 + d[i][1]//100
                dp[i][j + 1][1] += 1

        if i > 0:
            if j  >= d[i][0]:
                if dp[i - 1][j+1 - d[i][0]][0] + d[i][1] // 100 > dp[i][j + 1][0]:
                    
                    dp[i][j + 1][0] = dp[i - 1][j+1 - d[i][0]][0] + d[i][1]// 100
                    dp[i][j + 1][1] = d[i][0]
            if dp[i-1][j+1][0] > dp[i][j + 1][0]:
                dp[i][j + 1][0] = dp[i-1][j+1][0]
                dp[i][j + 1][1] = 0

        if dp[i][j + 1][0] >= A:
            okcount[i] = j+1
            break


ans = max

for i in okcount:
    ans = min(ans, i)

print(ans)

Submission status: Wrong Answer

Solution code:

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


A = G/100
max = 1

for d_i in d:
    max += d_i[0]

dp = [[[0, 0] for i in range(max+1)] for j in range(D)]

okcount = [max for j in range(D)]

for i in range(D):
    for j in range(max):

        dp[i][j + 1][0] = dp[i][j][0]
        dp[i][j + 1][1] = dp[i][j][1]

        if dp[i][j][1] + 1 < d[i][0]:
            if dp[i][j][0] + i + 1 > dp[i][j+1][0]:
                dp[i][j + 1][0] += i + 1
                dp[i][j + 1][1] += 1
        elif dp[i][j][1] + 1 == d[i][0]:
            if dp[i][j][0] + i + 1 + d[i][1]//100 > dp[i][j + 1][0]:
                dp[i][j + 1][0] += i + 1 + d[i][1]//100
                dp[i][j + 1][1] += 1

        if i > 0:
            if j  >= d[i][0]:
                if dp[i - 1][j+1 - d[i][0]][0] + d[i][1] // 100 > dp[i][j + 1][0]:
                    print("(●・▽・●)")
                    dp[i][j + 1][0] = dp[i - 1][j+1 - d[i][0]][0] + d[i][1]// 100
                    dp[i][j + 1][1] = d[i][0]
            if dp[i-1][j+1][0] > dp[i][j + 1][0]:
                dp[i][j + 1][0] = dp[i-1][j+1][0]
                dp[i][j + 1][1] = 0

        if dp[i][j + 1][0] >= A:
            okcount[i] = j+1
            break

print(dp)
ans = max

for i in okcount:
    ans = min(ans, i)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
D, G = map(int, input().split())
p=[0]
c=[0]
for i in range(D):
  a, b = [int(i) for i in input().split()]
  p.append(a)
  c.append(b)

#残りgと100iの問題に費やした回数を返す
def solve(g, i):
  #全問解いても終わらないケース
  if p[i]*100*i + c[i] < g:
    return g-(p[i]*100*i + c[i]), p[i]
  #ボーナス無しでも終わるケースはgを超えるのに必要な問題数だけ解く
  elif p[i]*100*i > g:
    return 0, math.ceil(g/i/100)
  #ボーナスあれば終わるケースはちょうどp[i]問解く
  else:
    return 0, p[i]

def func(g, remain):
  m = 0
  for j in remain:
    new_remain = remain
    new_remain.remove(j)
    g, n = solve(g, j)
    if g>0:
      n += func(g, new_remain)
    if m==0:
      m=n
    else:
      m=min(m,n)
  return m

remain=[]
for k in range(1,D+1):
  remain.append(k)
ans = func(G,remain)
print(ans)

Submission status: Wrong Answer

Solution code:
d, g = (int(_) for _ in input().split())
p = [0]*d
c = [0]*d
for i in range(d):
    p[i], c[i] = (int(_) for _ in input().split())

q = [(p[i], 100*(i+1)*p[i]+c[i], 100*(i+1)+float(c[i]/p[i]), i) for i in range(d)]

q = sorted(q, key=lambda x:(-x[1], x[0]))
#print(q[0], q[0][1], q[0][-1])

count = 0
while g > 0 :
    if g >= q[0][1]:
        q = sorted(q, key=lambda x:(-x[2], -x[1]))
        g -= q[0][1]
        count += q[0][0]
        q.pop(0)
        q = sorted(q, key=lambda x:(-x[1], x[0]))
    else:
        q = sorted(q, key=lambda x:(x[0], -x[1]))
        idx = 0
        while g > q[idx][1]:
            idx += 1
        tmp1 = q[idx][0]
        #print('g', g)
        #print('tmp1', tmp1)

        idx = max([x for _,_,_,x in q])
        #print(idx, p[idx])
        if int(g/(100*(idx+1)) + 0.5) <= p[idx]:
            tmp2 = int(g/(100*(idx+1)) + 0.5)
            #print('tmp2', tmp2)

            count += min(tmp1, tmp2)
        else:
            count += tmp1
        g=0

    #print(count)

print(count)

Submission status: Wrong Answer

Solution code:
n,g=map(int,input().split())
p=[0]*n
c=[0]*n
for i in range(n):
    p[i],c[i]=map(int,input().split())
cnt=0
cnt_2=0
ans,ans_2=0,0
while g<=ans:
    for i in range(p[d]):
        ans+=d*100
        cnt+=1
    ans+=c[d]
    d-=1
i=1
while g<=ans_2:
    for i in range(n):
        ans_2+=100*i
        cnt_2+=1
    ans+=c[i-1]
    i+=1
print(min(cnt,cnt_2))

Submission status: Wrong Answer

Solution code:
d,g=map(int,input().split())
pc=[list(map(int,input().split()))for _ in [0]*d]
r=1000
for k in range(2**d):
    s=''.join((['0']*d+list(str(bin(k))[2:]))[-d:])
    vs=[(pc[i][0]*100*(i+1)+pc[i][1])*int(s[i]) for i in range(d)]
    v=sum(vs)
    tr=sum([pc[i][0]*int(s[i]) for i in range(d)])
    for j in reversed(range(d)):
        if s[j]=='1':continue
        t=max((g-v)//((j+1)*100),0)
        if t<pc[j][0]:
            r=min(r,t+tr)
            #print(i,r,v,j,tr,t,vs,[pc[i][0]*int(s[i]) for i in range(d)])
            break
        else:
            v+=(j+1)*100*(pc[j][0]-1)
            tr+=pc[j][0]-1
    if k==2**d-1:r=min(r,tr)
print(r)