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: Runtime Error

Solution code:
import numpy as np

D,G = map(int, input().split())
P = []
C = []

for i in range(D):
#    p,c = min(100,(i+1)*20),1000*(i+1)#map(int,input().split())
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)

cnt = [0 for _ in range(D)]

ans = sum(P)
cnt_tar = 0

for i in range(D):
    tar = i

    ind_list = list(range(D))
    ind_list.remove(tar)
    ind_list = np.array(ind_list)

    P_part = np.array(P[:tar] + P[tar+1:])
    C_part = np.array(C[:tar] + C[tar+1:])

    cnt_part = np.zeros(D-1,dtype=int)#[0 for _ in range(D-1)]
    point_part = np.zeros(D-1,dtype=int)#[0 for _ in range(D-1)]

    bit_list = np.ones(D-1,dtype=int)
    point_part_max = np.sum(((ind_list+1) * 100 * P_part + C_part)*bit_list)

    cnt_tar_min = max(0,(G - point_part_max)//((tar+1)*100))

    for cnt_tar in range(cnt_tar_min,P[tar]+1):
        point_base = cnt_tar*(tar+1)*100

        num_base   = cnt_tar + C[tar]*max(0,cnt_tar-P[tar] + 1)

        if point_base >= G or num_base >= ans:
            num = num_base
            ans = min(ans,num)
            break
        elif point_base + point_part_max >= G:

            for bit_seed in range(2**(D-1)):

                s_bit = (format(bit_seed, '#011b'))[::-1]
                bit_list = np.array(list(s_bit[:D-1]),dtype=int)

                cnt_part = P_part*bit_list
                num = num_base + np.sum(cnt_part)
                if num > ans:
                    continue

                point_part = cnt_part * (ind_list+1) * 100 + C_part*bit_list
                point = point_base + np.sum(point_part)

                if point >= G:
                    ans = min(ans,num)

print(ans)
#     while cnt_part != P_part:
#     ind = 0

#     cnt = kuriage(cnt,P,ind,tar,C,G)
#     print(cnt)
#     if cnt[tar] == -1:
#         cnt = [0 for _ in range(D)]
#         tar += 1

#     if point_over(cnt,P,C,G) and ans > sum(cnt):
#         ans = min(ans, sum(cnt))
# #            print(ans)

# print(ans)


# def kuriage(cnt,P,ind,tar,C,G):

#     if cnt[ind] == 0:
#         cnt[ind:ind+1] = P[ind:ind+1]
#     elif cnt[ind] == P[ind]:
#         if 0 in cnt[:tar] and 0 in cnt[tar+1:]:
#             if ind+1 == tar:
#                 kuriage(cnt,P,ind+2, tar, C, G)
#             else:
#                 kuriage(cnt,P,ind+1, tar, C, G)
#         else:
#             if C[tar] != P[tar]:
#                 C[tar] = C[tar] + 1
#             else:
#                 C[tar] = -1
#     return cnt
# def point_over(cnt,P,C,G):
#     point = 0
#     for i in range(len(P)):
#         point += cnt[i]*100*(i+1)
#         if cnt[i] == P[i]:
#             point += C[i]

#         if point >= G:
#             return True

#     if point < G:
#         return False

# def point(cnt,P,C):
#     point = 0

#     for i,cnt_s in enumerate(cnt):
#         print(cnt_s,'ok')
#         if cnt_s == 0:
#             point += 0
#         else:
#             point += cnt[i]*100*(i+1) + C[i]
#     return point

Submission status: Runtime Error

Solution code:
d, g = map(int, input().split())
p = []
c = []
for i in range(d):
    a,b = map(int, input().split())
    p.append(a)
    c.append(b)

def recursive_min(score, pi):
    # 点数と（残っている）問題の数に対してminの問題数を返す
    min = float('inf')
    for i in range(d):
        if pi[i] > 1:
            next_pi = pi[:]
            next_pi[i] += -1
            next_score = score-(i+1)*100
        elif pi[i] == 1:
            next_pi = pi[:]
            next_pi[i] += -1
            next_score = score-c[i]-(i+1)*100
        else:
            continue

        if next_score<=0:
            return 1
        cand_min = 1+recursive_min(next_score, next_pi)
        if cand_min<min:
            min = cand_min
    return min

print(recursive_min(g, p))

Submission status: Runtime Error

Solution code:
import itertools

def all_comb(iterable):
    for i in range(0, len(iterable) + 1):
        comb = itertools.combinations(iterable, i)
        for pair in comb:
            yield(pair)

def min_solve(goal_point, solve, pc_list):
    solve_point = sum([pc[0] * pc[2] + pc[1] for pc in solve])
    solve_num = sum([pc[0] for pc in solve])
    nc_solve = set(pc_list) - set(solve)
    if solve_point > goal_point:
        return float('Inf')
    if solve_point == goal_point:
        return solve_num
    nc_solve_max = max(nc_solve, key=lambda pc:pc[2])
    if solve_point + (nc_solve_max[0] - 1) * nc_solve_max[2]  >= goal_point:
	min_solve = int((goal_point - solve_point) / nc_solve_max[2] + solve_num)
        return min_solve
    else:
        return float('Inf')

if __name__=='__main__':
    D, G = map(int, input().split())
    pc_list = []
    for i in range(D):
	(p, c) = map(int, input().split())
	pc_list.append((p, c, (i + 1) * 100))
    min_num = min([min_solve(G, solve, pc_list) for solve in all_comb(pc_list)])
    print(min_num)

Submission status: Runtime Error

Solution code:
#!/usr/bin/python3                                                                                                                                                     

import itertools
import sys

def printe(value):
    print(value, file=sys.stderr)

def all_comb(iterable):
    for i in range(0, len(iterable) + 1):
        comb = itertools.combinations(iterable, i)
        for pair in comb:
            yield(pair)

def min_solve(goal_point, solve, pc_list):
    solve_point = sum([pc[0] * pc[2] + pc[1] for pc in solve])
    solve_num = sum([pc[0] for pc in solve])
    printe("solve={}".format(solve))
    printe("solve_point={}".format(solve_point))
    printe("solve_num={}".format(solve_num))

    nc_solve = set(pc_list) - set(solve)
    if solve_point > goal_point:
        return float('Inf')
    if solve_point == goal_point:
	return solve_num
    nc_solve_max = max(nc_solve, key=lambda pc:pc[2])
    if solve_point + (nc_solve_max[0] - 1) * nc_solve_max[2]  >= goal_point:
	min_solve = int((goal_point - solve_point) / nc_solve_max[2] + solve_num)
        return min_solve
    else:
        return float('Inf')

if __name__=='__main__':
    D, G = map(int, input().split())
    pc_list = []
    for i in range(D):
	(p, c) = map(int, input().split())
	pc_list.append((p, c, (i + 1) * 100))
    min_num = min([min_solve(G, solve, pc_list) for solve in all_comb(pc_list)])
    print(min_num)

Submission status: Runtime Error

Solution code:
D,G=map(int,input().split())
p,c=[0]*D,[0]*D
cell=[]
for i in range(D):
    p[i],c[i]=map(int,input().split())
    cell.append([-1]*102)

m=0,0,0
mondai=[]
for i in range(2**D,2**(D+1)):
    s=(bin(i))[3:]
    a,b=0,0
    for j in range(D):
        if s[j]=='1':
            a,b=a+p[j],b+100*(j+1)*p[j]+c[j]
        else:
            m=j
    if G<b:
        mondai.append(a)
    if G-p[m]*100*(m+1)<b<G:
        ad=(G-b)//(100*(m+1))
        mondai.append((a+ad))
print(min(mondai))

Submission status: Runtime Error

Solution code:
d,g = map(int,input().split())
ps=[]
cs=[]
counts = []
count = 0
visited = [0 for i in range(d)]
sums=0


for i in range(d):
  p,c = map(int,input().split())
  ps.append(p)
  cs.append(c)

def dfs(i,count,visited,sums):
  if visited[i] != ps[i]:
    local_visited=visited[:]
    count += 1
    sums += (i+1)*100
    local_visited[i] += 1
    if local_visited[i] == ps[i]:
      sums += cs[i]
    if sums >= g:
      counts.append(count)
      return
    for i in range(d):
      dfs(i,count,local_visited,sums)


for i in range(d):
  dfs(i,count,visited,sums)


print(min(counts))

Submission status: Runtime Error

Solution code:
import math
d,g = map(int, input().split())
list_prob = []
for i in range(0,d):
    list_prob.append(list((map(int,input().split()))))
#print(list_prob)

list_sum = [0]*d
for i in range(0,d):
    list_sum[i] = (i+1) * 100 * list_prob[i][0] + list_prob[i][1]
#print(list_sum)

list_perf = [0]*d
for i in range(0,d):
    list_perf[i] = list_sum[i] / list_prob[i][0]
#print(list_perf)
count = 0
max_perf = max(list_perf)
idx = list_perf.index(max_perf)
while g >= list_sum[idx]:
    g -= list_sum[idx]
    count += list_prob[idx][0]
    list_perf[idx] = 0
    list_sum[idx] = 0
    list_prob[idx] = [0,0]
    max_perf = max(list_perf)
    idx = list_perf.index(max_perf)
count_list = [0]*d
#print(list_prob)
#print(g)
#print(list_sum)
for i in range(0,d):
    if g > list_sum[i]:
        count_list[i] = math.inf
    elif g > list_prob[i][0] * (i+1) * 100:
        count_list[i] = list_prob[i][0]
    else:
        count_list[i] = g / (100*(i+1))
#print(count_list)
#print(count)
min_count = min(count_list)
print(int(count + min_count))

Submission status: Runtime Error

Solution code:
import math

D,G = map(int,input().split())
PC = [0] + [[int(i) for i in input().split()] for _ in range(D)]

ans = 1e9
for i in range(2**D - 1):
    inSolve = -1
    score_tmp = 0
    solved = 0
    for j in range(D):
        if (i>>j)%2 == 1:
            score_tmp += (j+1)*100*PC[j][0]+PC[j][1]
            solved += PC[j][0]
        else:
            inSolve = max(j,inSolve)
    if score_tmp < G and inSolve != -1:
        if math.ceil((G-score_tmp)/((inSolve+1)*100)) <= PC[inSolve][0]:
            ans = min(ans,solved + math.ceil((G-score_tmp)/((inSolve+1)*100)))
    elif score_tmp >= G:
        ans = min(ans,solved)
print(ans)

Submission status: Runtime Error

Solution code:
import unionfind

Submission status: Runtime Error

Solution code:
# coding: utf-8
ranknum,goal = list(map(int,input().split()))
probnum = [0]*ranknum
bonus = [0]*ranknum
compscore = [0]*ranknum


for i in range(ranknum):
    probnum[i], bonus[i] = list(map(int,input().split()))
    #各ランクをコンプした場合に得られる得点をcompscoreに格納しておく。
    compscore[i] = 100*(i+1)*probnum[i] + bonus[i]

from itertools import product
from math import ceil

#得点Gを達成する最小の問題正解数minprobを初期化。前提により必ず1000以下になるので、1001で初期化しておく。
minprob = 1001

#各ランクの問題をコンプするか否かの2^ranknum通りをループ処理する。
for c in product(range(2),repeat=ranknum):
    # print(c)
    score = 0
    solvedprob = 0
    notcompedindex = -1

    #コンプした問題について、得点をcompscoreに、正解数をsolvedprobnumに格納する。
    for i in range(ranknum):
        if c[i] == 1:
            score +=  compscore[i]
            solvedprob +=  probnum[i]
        #コンプされていないランクのインデックスのうち最大のものをnotcompedindexに格納しておく。
        else:
            notcompedindex = i
    # print("score:" + str(score))
    # print("solvedprob:" + str(solvedprob))
    # print("notcompedindex:" + str(notcompedindex))
    
    #コンプした問題だけでgoalに達さず、かつ、コンプしていない最高ランクの問題をコンプ寸前まで解けばゴールに達する場合、
    #ゴールをぎりぎり達成するところまで正解した状態へと、scoreとsolvedprobを更新する。
    if score <= goal and score+100*(notcompedindex+1)*(probnum[notcompedindex]-1) >= goal:
        # print("addition")
        solvedprob += ceil((goal - score)/(100*(notcompedindex+1)))
        score += ceil((goal - score)/(100*(notcompedindex+1)))*100*(notcompedindex+1)
    
    #最終的にゴールを達成している場合、正解数が暫定最小ならば、それをminprobに格納しておく。
    if score >= goal:
        minprob = min(minprob, solvedprob)  
    # print("score:" + str(score))
    # print("solvedprob:" + str(solvedprob))
    # print("minprob:" + str(minprob))

print(minprob)

# print(ranknum)
# print(goal)
# print(problemnum)
# print(bonus)
# print(completescore)

Submission status: Runtime Error

Solution code:
# coding: utf-8
ranknum,goal = list(map(int,input().split()))
probnum = [0]*ranknum
bonus = [0]*ranknum
compscore = [0]*ranknum


for i in range(ranknum):
    probnum[i], bonus[i] = list(map(int,input().split()))
    #各ランクをコンプした場合に得られる得点をcompscoreに格納しておく。
    compscore[i] = 100*(i+1)*probnum[i] + bonus[i]

from itertools import product
from math import ceil

#得点Gを達成する最小の問題正解数minprobを初期化。前提により必ず1000以下になるので、1001で初期化しておく。
minprob = 1001

#各ランクの問題をコンプするか否かの2^ranknum通りをループ処理する。
for c in product(range(2),repeat=ranknum):
    print(c)
    score = 0
    solvedprob = 0
    notcompedindex = -1

    #コンプした問題について、得点をcompscoreに、正解数をsolvedprobnumに格納する。
    for i in range(ranknum):
        if c[i] == 1:
            score +=  compscore[i]
            solvedprob +=  probnum[i]
        #コンプされていないランクのインデックスのうち最大のものをnotcompedindexに格納しておく。
        else:
            notcompedindex = i
    print("score:" + str(score))
    print("solvedprob:" + str(solvedprob))
    print("notcompedindex:" + str(notcompedindex))
    
    #コンプした問題だけでgoalに達さず、かつ、コンプしていない最高ランクの問題をコンプ寸前まで解けばゴールに達する場合、
    #ゴールをぎりぎり達成するところまで正解した状態へと、scoreとsolvedprobを更新する。
    if score <= goal and score+100*(notcompedindex+1)*(probnum[notcompedindex]-1) >= goal:
        print("addition")
        solvedprob += ceil((goal - score)/(100*(notcompedindex+1)))
        score += ceil((goal - score)/(100*(notcompedindex+1)))*100*(notcompedindex+1)
    
    #最終的にゴールを達成している場合、正解数が暫定最小ならば、それをminprobに格納しておく。
    if score >= goal:
        minprob = min(minprob, solvedprob)  
    print("score:" + str(score))
    print("solvedprob:" + str(solvedprob))
    print("minprob:" + str(minprob))

print(minprob)

# print(ranknum)
# print(goal)
# print(problemnum)
# print(bonus)
# print(completescore)

Submission status: Runtime Error

Solution code:
# encoding: utf-8

P_MAX = 100

num_and_pnt = lambda x: [int(x[0]), int(x[1]) // 100]

def mycounter(item, G):
    Gtmp = (item[1] + 1) * item[2] + item[3]
    p_th = item[2]
    for i in range(item[2]):
        if Gtmp < G: break
        else:
            p_th -= 1
            Gtmp = (item[1] + 1) * p_th
    return p_th + 1

D, G = num_and_pnt(input().split())

# [flag, index, pi, ci]
pc = [[1, i] + num_and_pnt(input().split()) for i in range(D)]

cnt = 0
while True:
    # last point

    state = -1
    p_tmp = P_MAX
    for item in filter(lambda x: x[0] > 0, pc):
        Gtmp = (item[1] + 1) * item[2] + item[3]
        if G <= Gtmp:
            p = mycounter(item, G)
            if p < p_tmp:
                state = item[1]
                p_tmp = p
    # escape
    if state > -1:
        cnt += p_tmp
        # print("#", (state + 1) * 100, p_tmp)
        break
    # completed point
    item = max(list(filter(lambda x: x[0] > 0, pc)), key=lambda x: x[1] + x[3] / x[2])
    G -= (item[1] + 1) * item[2] + item[3]
    cnt += item[2]
    pc[item[1]][0] = 0
    # print("#", (item[1] + 1) * 100, item[2], G)
    
print(cnt)

Submission status: Runtime Error

Solution code:
# encoding: utf-8

P_MAX = 100

num_and_pnt = lambda x: [int(x[0]), int(x[1]) // 100]

def mycounter(item, G):
    Gtmp = (item[1] + 1) * item[2] + item[3]
    p_th = item[2]
    for i in range(item[2]):
        if Gtmp < G: break
        else:
            p_th -= 1
            Gtmp = (item[1] + 1) * p_th
    return p_th + 1

D, G = num_and_pnt(input().split())

# [flag, index, pi, ci]
pc = [[1, i] + num_and_pnt(input().split()) for i in range(D)]

cnt = 0
while True:
    # last point
    # print(G * 100, cnt, pc)
    state = -1
    p_tmp = P_MAX
    for item in filter(lambda x: x[0] > 0, pc):
        Gtmp = (item[1] + 1) * item[2] + item[3]
        if G <= Gtmp:
            p = mycounter(item, G)
            if p < p_tmp:
                # print(G * 100, (item[1] + 1) * 100, p)
                state = item[1]
                p_tmp = p
    # escape
    if state > -1:
        cnt += p_tmp
        break
    # completed point
    # print(pc)
    item = max(flist(ilter(lambda x: x[0] > 0, pc), key=lambda x: x[1] + x[3] / x[2]))
    G -= (item[1] + 1) * item[2] + item[3]
    cnt += item[2]
    pc[item[1]][0] = 0
    
print(cnt)

Submission status: Runtime Error

Solution code:
# encoding: utf-8

P_MAX = 100

num_and_pnt = lambda x: [int(x[0]), int(x[1]) // 100]

def mycounter(item, G):
    Gtmp = (item[1] + 1) * item[2] + item[3]
    p_th = item[2]
    for i in range(item[2]):
        if Gtmp < G: break
        else:
            p_th -= 1
            Gtmp = (item[1] + 1) * p_th
    return p_th + 1

D, G = num_and_pnt(input().split())

# [flag, index, pi, ci]
pc = [[1, i] + num_and_pnt(input().split()) for i in range(D)]

cnt = 0
while True:
    # last point
    # print(G * 100, cnt, pc)
    state = -1
    p_tmp = P_MAX
    for item in filter(lambda x: x[0] > 0, pc):
        Gtmp = (item[1] + 1) * item[2] + item[3]
        if G <= Gtmp:
            p = mycounter(item, G)
            if p < p_tmp:
                # print(G * 100, (item[1] + 1) * 100, p)
                state = item[1]
                p_tmp = p
    # escape
    if state > -1:
        cnt += p_tmp
        break
    # completed point
    # print(pc)
    item = max(filter(lambda x: x[0] > 0, pc), key=lambda x: x[1] + x[3] / x[2])
    G -= (item[1] + 1) * item[2] + item[3]
    cnt += item[2]
    pc[item[1]][0] = 0
    
print(cnt)

Submission status: Runtime Error

Solution code:
# encoding: utf-8

P_MAX = 100

num_and_pnt = lambda x: [int(x[0]), int(x[1]) // 100]

def mycounter(item, G):
    Gtmp = (item[1] + 1) * (item[2] - 1)
    p = item[2]
    for i in range(p):
        if Gtmp < G: break
        else:
            Gtmp -= (item[1] + 1)
            p -= 1
    return p

D, G = num_and_pnt(input().split())

# [flag, index, pi, ci]
pc = [[1, i] + num_and_pnt(input().split()) for i in range(D)]

cnt = 0
while True:
    # print(pc)
    # last point
    state = -1
    p_tmp = P_MAX
    for item in filter(lambda x: x[0] > 0, pc):
        Gtmp = (item[1] + 1) * item[2] + item[3]
        if G <= Gtmp:
            p = mycounter(item, G)
            if p < p_tmp:
                state = item[1]
                p_tmp = p
    # escape
    if state > -1:
        cnt += p_tmp
        break
    # completed point
    item = max(filter(lambda x: x[0] > 0, pc), key=lambda x: x[1] + x[3] / x[2])
    G -= (item[1] + 1) * item[2] + item[3]
    cnt += item[2]
    pc[item[1]][0] = 0
    
print(cnt)

Submission status: Runtime Error

Solution code:
from collections import deque

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

Q = deque([])
H = []

for pp in range(1, pc[0][1] + 1):
    cp = pc[0][2] if pc[0][1] == pp else 0
    Q.append((1, pp, pc[0][0] * pp + cp))

while Q:
    q = Q.popleft()

    if q[2] >= G:
        H.append(q[1])
        continue

    if q[0] >= D:
        continue

    for pp in range(1, pc[q[0]][1] + 1):
        cp = pc[q[0]][2] if pc[q[0]][1] == pp else 0
        Q.append((q[0] + 1, pp, pc[q[0]][0] * pp + cp,))

print(min(H))

Submission status: Runtime Error

Solution code:
D, G = input().split()
p = [0]*D
c = [0]*G
for i in range(D):
  p[i], c[i] = input().split()
for i in range(D): print(f"%d %d", p[i], c[i])

Submission status: Runtime Error

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

A=[map(int,raw_input().split()) for i in range(D)]

N=1000
dp=[ [ float("-inf") for i in range(N+100)]  for j in range(D) ] 

p=A[0][0]
c=A[0][1]


for i in range(1,p+1):
	if i==p: dp[0][i]=i*100+c
aa	else: dp[0][i]=i*100

for i in range(D):
	dp[i][0]=0



for k in range(1,D):
	p=A[k][0]    # number of problems per line
	c=A[k][1]    # bonus

	for i in range(N):		         #dp[k][i]
		for j in range(1,p+1):    #number of problems per line
			dp[k][i+j]=max( dp[k][i+j], dp[k-1][i]+j*(k+1)*100, dp[k-1][i+j] )
		dp[k][i+j]=max( dp[k][i+j], dp[k-1][i]+j*(k+1)*100+ac,dp[k-1][i+j] )



for idx,i in enumerate(dp[D-1]):
	if i>=G:
		print idx
		quit()

Submission status: Runtime Error

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

S=list(itertools.product(range(2),repeat=D))
ans=sum(p)
for seq in S:
    score=0
    prove=0
    for i in range(D):
        if seq[i]==1:
            score+=(p[i]*100*(i+1)+c[i])
            prove+=p[i]
    if score>G:
        continue
    j=-1
    for i in range(D):
        if seq[i]==0:
            j=i
    if (p[j]*100*(j+1)+c[j]+score<G):
        continue
    if (p[j]*100*(j+1)+score<G):
        continue
    k=(score-G)//(-(j+1)*100)
    prove+=k
    score+=k*100*(j+1)
    if ans>prove:
        ans=prove
print(ans)

Submission status: Runtime Error

Solution code:
D,G=map(int,raw_input().split())
G=G/100

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

S=6000

dp=[ [ float("inf") for i in range(S)]  for j in range(D) ] 
a=P[0][0]
b=P[0][1]/100

for i in range(a+1):
	if i==a: dp[0][i+b]=i
	else: dp[0][i]=i

for j in range(D): dp[j][0]=0


for i in range(1,D):
	a=P[i][0]
	b=P[i][1]/100


	for s in range(S):
		for k in range(1,a):
			if s-(k*(i+1)) >=0:
				dp[i][s]=min( dp[i-1][s-(k*(i+1))]+k, dp[i-1][s] )
		if s-( a*(i+1)+b )>=0:
			dp[i][s]=min( dp[i-1][s-( a*(i+1)+b ) ]+a, dp[i-1][s] )

#print dp	
print dp[D-1][G]

Submission status: Runtime Error

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

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

S=6000

dp=[ [ float("inf") for i in range(S)]  for j in range(D) ] 
a=P[0][0]
b=P[0][1]/100

for i in range(a+1):
	if i==a: dp[0][i+b]=i
	else: dp[0][i]=i

for j in range(D): dp[j][0]=0


for i in range(1,D):
	a=P[i][0]
	b=P[i][1]/100


	for s in range(S):
		for k in range(1,a):
			if s-(k*(i+1)) >=0:
				dp[i][s]=min( dp[i-1][s-(k*(i+1))]+k, dp[i-1][s] )
		if s-( a*(i+1)+b )>=0:
			dp[i][s]=min( dp[i-1][s-( a*(i+1)+b ) ]+a, dp[i-1][s] )

	
ans=float("inf")
for i in range(G/100,S):
	ans=min(ans,dp[D-1][i] )

print ans

Submission status: Runtime Error

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

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

S=6000

dp=[ [ float("inf") for i in range(S)]  for j in range(D) ] 
c=P[0][0]
s=P[0][1]

for i in range(c+1):
	if i==c: dp[0][i+s/100]=i
	else: dp[0][i]=i

for j in range(D): dp[j][0]=0


for i in range(1,D):
	a=P[i][0]
	b=P[i][1]/100

	for k in range(1,a):
		for s in range(S):
			if s-(k*(i+1)) >=0:
				dp[i][s]=min( dp[i-1][s-(k*(i+1))]+k, dp[i-1][s] )
	for s in range(S):
		if s-( a*(i+1)+b )>=0:
			dp[i][s]=min( dp[i-1][s-( a*(i+1)+b ) ]+a, dp[i-1][s] )

	
ans=float("inf")
for i in range(G/100,S):
	ans=min(ans,dp[D-1][i] )

print ans

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Aug  5 19:16:59 2018
ABC104C
@author: maezawa
"""
import math

d, g = list(map(int, input().split()))
p = []
c = []
for i in range(d):
    pi, ci = list(map(int, input().split()))
    p.append(pi)
    c.append(ci)
 
min_cnt = 10**11 
    
for i in range(2**d):
    istr = '0'*d + format(i,'b')
    used = []
    cnt = 0
    maney = 0   
    for j in range(d):
        if istr[-1-j] == '1':
            maney += c[j]+p[j]*(j+1)*100
            cnt += p[j]
            used.append(j)
    if maney > g:
        if min_cnt > cnt:
            min_cnt = cnt
            #print(istr)
            continue
    else:
        k = d-1
        while k>=0:
            if k not in used:
                break 
            k -= 1
        rem = math.ceil((g-maney)/(100*(k+1)))
        if rem >= p[k]:
            continue
        else:
            cntp = cnt + rem
            if min_cnt > cntp:
                min_cnt = cntp
                #print(istr, rem)
                continue
    #print(min_cnt, istr)
print(min_cnt)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Aug  5 19:16:59 2018
ABC104C
@author: maezawa
"""
import math

d, g = list(map(int, input().split()))
p = []
c = []
for i in range(d):
    pi, ci = list(map(int, input().split()))
    p.append(pi)
    c.append(ci)
 
min_cnt = 10**11 
    
for i in range(2**d):
    istr = '0'*d + format(i,'b')
    used = []
    cnt = 0
    maney = 0   
    for j in range(d):
        if istr[-1-j] == '1':
            maney += c[j]+p[j]*(j+1)*100
            cnt += p[j]
            used.append(j)
    if maney > g:
        if min_cnt > cnt:
            min_cnt = cnt
            #print(istr)
            continue
    else:
        k = d-1
        while k<d:
            if k not in used:
                break 
            k -= 1
        rem = math.ceil((g-maney)/(100*(k+1)))
        if rem >= p[k]:
            continue
        else:
            cntp = cnt + rem
            if min_cnt > cntp:
                min_cnt = cntp
                #print(istr, rem)
                continue
    #print(min_cnt, istr)
print(min_cnt)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
using ll = long long;

int main(){
    ll d, g;
    cin >> d >> g;
    vector<ll> p, c;
    p.resize(d), c.resize(d);
    for(ll i = 0; i < d; ++i) cin >> p[i] >> c[i];
    
    ll res = 1 << 29;
    for(ll bit = 0; bit < (1 << d); ++bit){
        ll n = 0;
        ll sum = 0;
        for(ll i = 0; i < d; ++i){
            if(bit & (1 << i)) sum += c[i] + p[i] * 100 * (i + 1), n += p[i];
        }
        if(sum >= g) res = min(res, n);
        else{
            for(ll i = d - 1; i >= 0; --i){
                if(bit & (1 << i)) continue;
                for(ll j = 0; j < p[i]; j++){
                    if(sum >= g) break;
                    sum += 100 * (i + 1);
                    ++n;
                }
            } 
            res = min(res, n);
        }
    }
    cout << res << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
using ll = long long;

int main(){
    ll d, g;
    cin >> d >> g;
    vector<ll> p, c;
    p.resize(d), c.resize(d);
    for(ll i = 0; i < d; ++i) cin >> p[i] >> c[i];
    
    ll res = 1 << 30;
    for(ll bit = 0; bit < (1 << d); ++bit){
        ll n = 0;
        ll sum = 0;
        for(ll i = 0; i < d; ++i){
            if(bit & (1 << i)) sum += c[i] + p[i] * 100 * (i + 1), n += p[i];
        }
        if(sum >= g) res = min(res, n);
        else{
            for(ll i = d - 1; i >= 0; --i){
                if(bit & (1 << i)) continue;
                for(ll j = 0; j < p[i]; j++){
                    if(sum >= g) break;
                    sum += 100 * (i + 1);
                    ++n;
                }
            } 
            res = min(res, n);
        }
    }
    cout << res << endl;
}

Submission status: Runtime Error

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

import math, functools
def f(cur, n, left):
    if left <= 0:
        return n
    def g(cur, n, left):
        if cur in m: return m[cur]
        r = m[cur] = f(cur, n, left)
        return r
    ret = 10**9
    for x in pc:
        i, p, c = x
        if (1 << i) & cur: continue
        ip = i*100*p
        if ip > left:
            h = math.ceil(left / (i*100))
            ret = min(ret, n + h)
        else:
            if n + p >= ret: continue
            h = g(cur | (1 << i), n + p, left - ip - c)
            ret = min(ret, h)
    return ret

print(f(0, 0, G))

Submission status: Runtime Error

Solution code:
d ,g = map(int,input().split())
p = []
c = []
for _ in range(d):
    _p ,_c = map(int,input().split())
    p.append(_p)
    c.append(_c)
    
for ans in range(1,sum(p)):
    cost = ans
    ten = 0
    _p = p.copy()
    _c = c.copy()
    for _ in range(d):
        rate = [((i+1)*100*cost) if _p[i] > cost else _p[i]*(i+1)*100+_c[i] for i in range(d)]
        _rate = [rate[i]/cost if cost < _p[i] else 0 if _p[i] == 0 else rate[i]/_p[i] for i in range(d)]
        rmax = _rate.index(max(_rate))
        if cost < p[rmax]:
            _p[rmax] -= cost
            cost = 0
        else:
            cost -= _p[rmax]
            _p[rmax] = 0
            _c[rmax] = 0
        ten += rate[rmax]
        if cost == 0:
            break
    if ten >= g:
        break
    
print(ans)

Submission status: Runtime Error

Solution code:
d ,g = map(int,input().split())
p = []
c = []
for _ in range(d):
    _p ,_c = map(int,input().split())
    p.append(_p)
    c.append(_c)
    
for ans in range(1,sum(p)):
    cost = ans
    ten = 0
    _p = p.copy()
    _c = c.copy()
    for _ in range(d):
        rate = [((i+1)*100*cost) if _p[i] > cost else _p[i]*(i+1)*100+_c[i] for i in range(d)]
        _rate = [rate[i]/cost if cost < _p[i] else 0 if _p[i] == 0 else rate[i]/_p[i] for i in range(d)]
        rmax = _rate.index(max(_rate))
        if cost < p[rmax]:
            _p[rmax] -= cost
            cost = 0
        else:
            cost -= _p[rmax]
            _p[rmax] = 0
            _c[rmax] = 0
        ten += rate[rmax]
        print(ten)
        if cost == 0:
            break
    if ten >= g:
        break
    
print(ans)