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:
# 解法は正しいはずだがコーナーケースに引っかかるらしくWAが1個出る

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_max = 0
    for b in pset:
        if b:
            score += s[i]
            solved += p[i]
            comped_max = max(comped_max, i)
    return score, solved, comped_max


def left(norm, i):
    if norm <= 0:
        return 0
    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_max = complete(pset)
    solved += left(G - score, comped_max)
    ans = min(ans, solved)

print(ans)

Submission status: Runtime Error

Solution code:
def saisyo(p1, c1, G, j):
    l = []
    for p in range(p1):
        l.append(100 * j * p)
        
    l.append(100 * j * p1 + c1)
    
    for  i in range(p1+1):
        if l[i] >= G:
            return(i)
            break
        #return(str(l[-1]/p1))
        
def saisyo2(p1, c1, G, j):
    l = []
    for p in range(p1):
        l.append(100 * j * p)
        
    l.append(100 * j * p1 + c1)
    return(l[-1]/p1)

D, G = map(int, input().split(" "))
l2 = []
l3 = []
for i in range(D):
    P, C = map(int, input().split(" "))
    l2.append(saisyo(P, C, G, i + 1))

for k in range(D):
    if l2[k] == None:
        l3.append(saisyo2(P, C, G, k + 1))
    else:
        print(min(l2))

Submission status: Runtime Error

Solution code:
D, G = map(int, input().split(" "))
l2 = []
l3 = []
for i in range(D):
    P, C = map(int, input().split(" "))
    l2.append(saisyo(P, C, G, i + 1))

for k in range(D):
    if l2[k] == None:
        l3.append(saisyo2(P, C, G, k + 1))
    else:
        print(min(l2))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 21 21:03:37 2018

@author: kumac
"""

"""
R = int(input())
if(R < 1200):
    print('ABC')
elif(R < 2800):
    print('ARC')
else:
    print('AGC')
"""

"""
import re

S = input()

regex = r'A[a-z][a-z]*C[a-z]*[a-z]'
ans = re.match(regex, S)
if(ans != None):
    if(ans.span() == (0, len(S))):
        print('AC')
    else:
        print('WA')
else:
    print('WA')
"""

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 <= dp[:,j]):
        print(j)

Submission status: Runtime Error

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


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

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

used = [False for i in range(D)]


def check_goal(P, C, rest):
    result = []
    for i in range(len(P)):
        if used:
            continue
        if rest < 100 * (i + 1) * P[i]:
            result.append(math.ceil(rest // 100 * (i + 1)))
        elif rest <= 100 * (i + 1) * P[i] + C[i]:
            result.append(P[i])
        else:
            result.append(float("inf"))
    return result


def get_scores_best(P, C, rest):
    scores = [(100 * (i + 1), i) if 100 * (i + 1) * P[i] > rest else (100 *
                                                                      (i + 1) + C[i] / P[i], i) for i in range(len(P))]
    scores.sort(key=lambda x: x[0])
    scores.reverse()
    while True:
        j = 0
        if used[scores[j][1]]:
            j += 1
            continue
        else:
            return scores[j]


def judge(P, C, G):
    rest = G
    count = 0
    while True:
        count_list = check_goal(P, C, rest)
        if min(count_list) != float("inf"):
            count += min(count_list)
            return count
        else:
            score, i = get_scores_best(P, C, rest)
            count += P[i]
            rest -= 100 * (i + 1) * P[i] + C[i]
            print(rest)
            used[i] = True


print(judge(P, C, G))

Submission status: Runtime Error

Solution code:
import math

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

p = [0]*D
c = [0]*D
ac = [0]*D
at = [0]*D
for i in range(D):
	p[i], c[i] = list(map(int, input().split()))
	ac[i] = (i+1)*100 + c[i]/p[i]
	at[i] = (i+1)*p[i]*100 + c[i]

idx = range(D)
zz = zip(ac,idx)

zz = sorted(zz, reverse=True)

ac, idx = zip(*zz)

sum = 0
max = max(at)
solve = 0
for i in range(D):
	diff = G - sum
	if diff <= p[D-1] * D * 100:
		solve += math.ceil(diff/(D*100))
		break
	if max >= diff:
		stack = []
		for j,k in enumerate(at):
			if k >= diff:
				stack.append(j)
		min = min([p[l] for l in stack])
		if p[idx[i]] >= min:
			solve += min
			sum += (p.index(min)+1) * min * 100
			if sum > G:
				solve -= math.floor((sum-G)/( (p.index(min)+1)*100 ))
			break
	total = (idx[i]+1) * p[idx[i]] * 100 + c[idx[i]]
	sum += total
	solve += p[idx[i]]
	if sum < G:
		continue
	else:
		if diff <= c[idx[i]]:
			break
		else:
			solve -= math.floor((diff-c[idx[i]])/( (idx[i]+1)*100 ))
			break

print(solve)

Submission status: Runtime Error

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:
        continue
      else:
        minN=minN(minN,n+1)
      n=n-1
    
  i--
print(minN)

Submission status: Runtime Error

Solution code:
D, G = map(int, input().split())
arr = [[]]
base_ef = [0]
total_ef = [0]
for i in range(1, D+1):
    arr.append(list(map(int, input().split())))
    base_ef.append(100*i)
    total_ef.append(100*i + arr[i][1]/arr[i][0])

cnt = 0
rem = G
while rem =< 0:
    rem = rem - max(total_ef)
    cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
import math

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

p = [0]*D
c = [0]*D
ac = [0]*D
at = [0]*D
for i in range(D):
	p[i], c[i] = list(map(int, input().split()))
	ac[i] = (i+1)*100 + c[i]/p[i]
	at[i] = (i+1)*p[i]*100 + c[i]

idx = range(D)
zz = zip(ac,idx)

zz = sorted(zz, reverse=True)

ac, idx = zip(*zz)

sum = 0
max = max(at)
solve = 0
for i in range(D):
	diff = G - sum
	if diff <= p[D] * D * 100:
		solve += math.ceil(diff/(D*100))
		break
	if max >= diff:
		stack = []
		for j,k in enumerate(at):
			if k >= diff:
				stack.append(j)
		min = min([p[l] for l in stack])
		if p[idx[i]] >= min:
			solve += min
			sum += (p.index(min)+1) * min * 100
			if sum > G:
				solve -= math.floor((sum-G)/( (p.index(min)+1)*100 ))
			break
	total = (idx[i]+1) * p[idx[i]] * 100 + c[idx[i]]
	sum += total
	solve += p[idx[i]]
	if sum < G:
		continue
	else:
		if diff <= c[idx[i]]:
			break
		else:
			solve -= math.floor((diff-c[idx[i]])/( (idx[i]+1)*100 ))
			break

print(solve)

Submission status: Runtime Error

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

def solve(D, G, Ps, Cs):
    """ 平均値が高いやつから解いていく戦略 """
    AvgRank = {}
    for i in range(1, D+1):
        avg = (Ps[i] * 100 * i + Cs[i]) / Ps[i]
        AvgRank[i] = [Ps[i], avg]
    AvgRanks = sorted(AvgRank.items(), key=lambda x: -x[1][1])

    rest_Is = []
    for i in range(1, D+1):
        rest_Is.append(i)

    solved = 0
    rest_G = G
    while True:
        """
        (1) 残っている問題の中から一番点数高い問題を全て解いてOKなら、そうする
        (2) それがだめなら、最も高い平均値のやつを解く
        (3) (2)の問題を除外し、(1)に戻る
        """
        i = rest_Is[-1]
        if rest_G <= (Ps[i] * 100*i):
            solved += math.ceil(G/(100*i))
        else:
            solved += AvgRanks[0][1][0]
            now_i   = AvgRanks[0][0]
            rest_Is.remove(now_i)
            AvgRanks.pop(0)
            rest_G -= (Ps[now_i] * 100*now_i)
            if rest_G <= 0:
                break
            else:
                continue
    print(solved)


if __name__ == "__main__":
    D, G = list(map(int, input().split()))
    Ps = [0]
    Cs = [0]
    for i in range(D):
        p, c = list(map(int, input().split()))
        Ps.append(p)
        Cs.append(c)

    solve(D, G, Ps, Cs)

Submission status: Runtime Error

Solution code:
d, g = map(int, input().split())
p = [[0,0] for i in range(d)]
for i in range(d):
    p[i][0], p[i][1] = map(int, input().split())
ans = 0
sum = 0
i = d
j = 0
extra_ans = [p[i][0] * (i+1) * 100 + p[i][1] for i in range(d)]
while sum < g:
    j += 1
    ans += 1
    sum += i * 100
    if j == p[i-1][0]:
        sum += p[i-1][1]
        i -= 1
        j = 0
    if sum + extra_ans[i-2] >= g :
        tmp = ans + p[i-2][0]
if tmp < ans:
    ans = tmp
for i in range(d):
    if p[i][0] * (i+1) * 100 + p[i][1] >= g and p[i][0] < ans:
        ans = p[i][0]
print(ans)

Submission status: Runtime Error

Solution code:
D, G = map(int, input().split())
arr = [[]]
base_ef = [0]
total_ef = [0]
for i in range(1, D+1):
    arr.append(list(map(int, input().split())))
    base_ef.append(100*i)
    total_ef.append(100*i + arr[i][1]/arr[i][0])

cnt = 0
while True:

Submission status: Runtime Error

Solution code:
import itertools

d, g = [int(i) for i in input().split()]
p_list = []
c_list = []
for i in range(d):
    p, c = [int(j) for j in input().split()]
    p_list.append(p)
    c_list.append(c)

sample = list(itertools.permutations([i for i in range(d)]))
ans_list = []
ans_pattern_dict = {}
for per in sorted(sample, reverse=True):
    idx_list = list(per)
    score = 0
    num = 0
    for k, v in ans_pattern_dict.items():
        if idx_list[:len(k)] == k:
            continue
    for i in idx_list:
        s = 100 * (i + 1)
        p = p_list[i]
        c = c_list[i]
        if score + s * p + c < g:
            score += s * p + c
            num += p
            if len(ans_list) > 0 and min(ans_list) < num:
                break
            continue
        elif score + s * p + c == g:
            num += p
            ans_list.append(num)
            index = idx_list.index(i)
            ans_pattern_dict[idx_list[:index+1]] = True
            break
        elif g - score < s * p:
            if (g - score) % s == 0:
                num += (g - score) // s
            else:
                num += (g - score) // s + 1
            ans_list.append(num)
            index = idx_list.index(i)
            ans_pattern_dict[idx_list[:index + 1]] = True
            break
        else:
            num += p
            ans_list.append(num)
            index = idx_list.index(i)
            ans_pattern_dict[idx_list[:index + 1]] = True
            break

print(min(ans_list))

Submission status: Runtime Error

Solution code:
import math

d, g = list(map(int, input().split(" ")))
p = d*[0]
c = d*[0]
ans = []
for i in range(d):
    p[i], c[i] = list(map(int, input().split(" ")))

ans = []
for i in range(d):
    ans.append(100*(i+1)*p[i] + c[i])

pre = int(1e9)
tmp = 0
for j in range(d):
    for i in range(d):
        if(ans[i] >= g):
            if(p[i] < pre): pre = p[i]
            if(100*(i+1)*(p[i]-1) >= g):
                if(math.ceil(g / (100*(i+1))) < pre and math.ceil(g / (100*(i+1))) < p[i]): pre = math.ceil(g / (100*(i+1)))
    if(pre == int(1e9)):
        pans = []
        for i in range(d):
            pans.append(ans[i] / p[i])
        index = 0
        best = pans[0]
        for i in range(1, d, 1):
            if(best < pans[i]):
                index = i
                best = pans[i]
            elif(best == pans[i]):
                if(p[best] > p[i]):
                    index = i
                    best = pans[i]
        g -= ans[index]
        tmp += p[index]
        ans[index] = 0

print(pre + tmp)

Submission status: Runtime Error

Solution code:
D, G = map(int, input().split())
p = []
c = []
for i in range(D):
    P, C = map(int, input().split())
    p.append(P)
    c.append(C)

getPoint = [[] for i in range(max(p))]
#getPoint = [0 for i in range(max(p))]
#print(c)
for i in range(max(p)):
    for j in range(D):
        if p[j] - 1> i:
            getPoint[i].append((i + 1) * 100 * (j + 1))
        else:
            getPoint[i].append(p[j] * (j + 1) * 100 + c[j])

#print(getPoint)

def sarch(G, keypoint):
    i = 0
    print(G, keypoint, 1111)
    if max(getPoint[-1]) >= G:
        i = 0
        while True:
            if max(getPoint[i]) >= G:
                print(keypoint + i + 1)
                break
            i += 1
    else:
        G -= max(getPoint[-1])
        keypoint += max(p)
        for i in range(len(getPoint[-1])):
            if getPoint[-1][i] == max(getPoint[-1]):
                key = i
        del p[i]
        del getPoint[max(p) + 1:]
        for i in range(len(getPoint)):
            del getPoint[i][key]
        sarch(G, keypoint)

def sarch2(G, keypoint):
    if G < 0:
        return print(keypoint)
    num = sorted(getPoint[0])[-1]
    for i in range(len(getPoint[0])):
        if getPoint[0][i] == max(getPoint[0]):
            num = i
    i = 0
    while True:
        if getPoint[i][num] < max(getPoint[i]):
            G -= getPoint[i][num]
            keypoint = keypoint + i + 1
            for j in range(len(getPoint)):
                if j < i:
                    #print(j, i)
                    getPoint[j][num] = getPoint[j + i + 1][num]
                else:
                    getPoint[j][num] = getPoint[-1][num]
            sarch2(G, keypoint)
            break
        i += 1
        if i >= len(getPoint):
            break
i = 0
#sarch(G, 0)
sarch2(G, 0)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
D, G = map(int, input().split())

cp = [tuple(map(int, input().split())) for i in range(D)]
cpg = [(c, (i + 1) * 100, (i + 1) * 100 * c + p)
       for i, (c, p) in enumerate(cp)]

cnt = 0
while True:

    c, p, g = cpg.pop()
    if G - g > 0:
        if cpg:
            cn, pn, gn = cpg[-1]
            if G - gn <= 0:
                cnt += cn
                break

        G -= g
        cnt += c
        continue

    else:

        if G / p < c:
            cnt += G // p if G % p == 0 else G // p + 1
            break

        if cpg:
            cn, pn, gn = cpg[-1]
            if G - gn <= 0 and cn < c:
                cnt += cn
                break

        else:
            cnt += c
            break

print(cnt)

Submission status: Runtime Error

Solution code:
D, G =map(int,input().split())
import math
nobonuscount=0

j=D
while j>1:
    if nobonus>a[i][0]*(j)*100+a[i][1]:
        nobonus=nobonus-(a[i][0]*(i+1)*100+a[i][1])
        nobonuscount+=a[i][0]
    j=j-1
    print(nobonus)
    print(nobonuscount)
    print(j)
nobonuscount+=math.ceil(nobonus/((j)*100))
print (nobonus)

Submission status: Runtime Error

Solution code:
d,g = map(int,input().split( ))
num=[]
bns=[]

NUM=10**6

for i in range(d):
    a,b = map(int,input().split( ))
    num.append(a)
    bns.append(b)


for j in range(d):    
    #print(num,bns)
    #print(D,G)
    #print(D*100*num[D-1])
    
    D=d
    G=g
    
    n=0
    for i in range(D):
        if D*100*num[D-1] < G:
            G += -D*100*num[D-1]-bns[D-1]
            n += num[D-1]
            D += -1
        else:
            break
    
    #print(D,G,n)
    #print(num,bns)
    
    N=num[D-1]
    
    for i in range(D):
        k=1
        sum = (D-i)*100*k
        while sum < G and k < num[D-i-1]:
            k+=1
            sum = (D-i)*100*k
        if k==num[D-i-1]:
            sum+=bns[D-i-1]
        if sum >= G:
            N = min(N,k)
    #    print(sum,k)
    
    NUM = min(N+n,NUM)
#    print(NUM)
    
 print(NUM)

Submission status: Runtime Error

Solution code:
# cook your dish here
D,g = map(int,input().split())
p = []
c = []

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

#print(p)

d = [0]
cnt = 0

while d[-1] < g:
    while p[-1] == 0:
        p.pop(len(p)-1)
        c.pop(len(p)-1)
    k = -1
    
    r = d[-1] + (len(p))*100
    for i in range(len(p)):
        if len(d) >= p[i] and p[i] != 0:
            w = d[len(d)-p[i]] + 100*(i+1)*p[i] + c[i]
 #           print(p[i],i,c[i],len(d),w)
            if w > r:
                r = w
                k = i
    if k == -1:
        cnt += 1
        
    else:
        p[-1] += cnt
        p[k] = 0
        cnt = 0
        
    d.append(r)

#print(d)
print(len(d)-1)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
D, G = map(int, input().split())

cp = [tuple(map(int, input().split())) for i in range(D)]
cpg = [(c, (i + 1) * 100, (i + 1) * 100 * c + p)
       for i, (c, p) in enumerate(cp)]

cnt = 0
while True:
    c, p, g = cpg.pop()

    if G - g > 0:
        G -= g
        cnt += c
        continue

    else:

        if G / p < c:
            cnt += G // p if G % p == 0 else G // p + 1
            break

        if cpg:
            cn, pn, gn = cpg[-1]
            if G - gn <= 0 and cn < c:
                cnt += cn
                break
        else:
            cnt += c
            break

print(cnt)

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)

ans = 0

summary = [(100*(i+1), p) for i, p in enumerate(P)]
summary = list(reversed(sorted([((comp[0]*comp[1] + c)/comp[1], comp[0]*comp[1] + c, comp[0], comp[1], c) for comp, c in zip(summary, C)])))

for i in range(D):
    _, comp_sc, prob_sc, n_prob, cp_bonus = summary[i]
    if G > comp_sc:
        G -= comp_sc
        ans += n_prob
    else:
        score = [(s[2], s[3]) for s in summary[i:] if s[1] > G]
        remain = []
        for prob_sc, n_prob in score:
            if prob_sc * n_prob < G:
                remain.append(n_prob)
            else:
                counter = 0
                tmp = G
                while True:
                    tmp -= prob_sc
                    counter += 1
                    if tmp <= 0:
                        break
                remain.append(counter)
        ans += min(remain)
        break

print(ans)

Submission status: Runtime Error

Solution code:
# cook your dish here
D,g = map(int,input().split())
p = []
c = []

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

#print(p)

d = [0]
cnt = 0

while d[-1] < g:
    while p[-1] == 0:
        p.pop(len(p)-1)
        c.pop(len(p)-1)
    k = -1
    
    r = d[-1] + (len(p))*100
    for i in range(len(p)):
        if len(d) >= p[i] and p[i] != 0:
            w = d[len(d)-p[i]] + 100*(i+1)*p[i] + c[i]
 #           print(p[i],i,c[i],len(d),w)
            if w > r:
                r = w
                k = i
    if k == -1:
        cnt += 1
        
    else:
        p[-1] += cnt
        p[k] = 0
        
    d.append(r)

#print(d)
print(len(d)-1)

Submission status: Runtime Error

Solution code:
a = list(map(int,input().split()))
b = []
for i in range(a[0]):
	n,m = map(int,input().split())
	b.append([n,n*100*(i+1),m])
su = 10000
s = 0
sss = 0
ma = 0
m = 0
co = 0
c = 0
while a[1] > 0:
	for i in range(len(b)):
		if b[i][1] >= a[1]:
			ma = b[i][1]
			su = min(su,b[i][0] - (b[i][1] - a[1])//100//(i+1))
			co = i
		elif b[i][1]+b[i][2] >= a[1]:
			ma = b[i][1]+b[i][2]
			su = min(su,b[i][0])
			co = i
		m = max(m,b[i][1]+b[i][2])
		if m == b[i][1]+b[i][2]:
			s = b[i][0]
			c = i
	if ma != 0:
		sss += su
		break
	else:
		sss += s
		b.pop(c)
		a[1] -= m
	ma = 0
	su = 10000
print(sss)

Submission status: Runtime Error

Solution code:
import math
import copy

d, g = map(int, input().split())

scores = {}

for i in range(d):
    p, c = map(int, input().split())
    scores[i] = {
        'num' : p,
        'comp': c
    }



ans = 10000
def calc(scoreList, currentScore, ct):
    global ans, g
    # print("currentScore %d , %d " % (currentScore, ct))
    if currentScore >= g:
        if ct < ans:
            ans = ct
            # print("ok")
            # print(ans)
        return

    for i in range(d):
        score = scoreList[i]
        tempScore = currentScore
        if score['num'] == 0: continue

        tempScore += (i+1) * 100
        if score['num'] == 1:
            tempScore += score['comp']
        tempScoreList = copy.deepcopy(scoreList)
        tempScoreList[i]['num'] -= 1
        calc(tempScoreList, tempScore, ct+1)

calc(scores, 0, 0)
print(ans)

Submission status: Runtime Error

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

#100点、200点を1点、2点としていく

minSolve = [1000 for _ in range(G+1)] #どんなに多くても1000問解けば最高点
minSolve[0] = 0 #0点とるのには自明に0問

p = [0] #i点の問題数
c = [0] #i点問題のコンプリートボーナス

for _ in range(D):
    pi, ci = map(int,input().split())
    p.append(pi)
    c.append(ci//100)　#100で割っておく


#方針としてはvalue i weight 1のものが各pi個、value i*pi+ci weight piのものが各1個ある状態での
#0/1 knapsack問題なのではないかと考えるが実装力がなくABCとは別のタスクもあるので断念

Submission status: Runtime Error

Solution code:
import sys
d, g = map(int, input().split())
P = []
C = []
for i in range(d):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)

# Mに含まれる点数の問題をk問解いた時の最高点
# 例: M = [1, 2, 5]
def maxscore(k, M):
    # コンプ込みの平均点
    A = {}
    for i in M:
        if P[i-1] <= k:
            A[i] = 100*i + C[i-1]/P[i-1]
        else:
            A[i] = 100*i
    # 平均点の一番高いやつを採用
    i, a = sorted(A.items(), key=lambda x: -x[1])[0]
    #print(i, a)

    if P[i-1] <= k:
         score = 100*i*P[i-1] + C[i-1]
    else:
         return 100*i*k
    M.remove(i)
    score += maxscore(k-P[i-1], M)
    return score

k = 1
while(True):
    score = maxscore(k, list(range(1,d+1)))
    if score >= g:
        print(k)
        sys.exit(0)
    k += 1

Submission status: Runtime Error

Solution code:
d, g = [int(i) for i in input().split()]
p_list = []
c_list = []
for i in range(d):
    p, c = [int(j) for j in input().split()]
    p_list.append(p)
    c_list.append(c)


def greedy():
    score = 0
    num = 0
    for i in range(d)[::-1]:
        s = 100 * (i+1)
        c = c_list[i]
        p = p_list[i]
        if score + s*p_list[i] + c < g:
            score += s*p_list[i] + c
            num += p
            continue
        elif score + s*p_list[i] + c == g:
            num += p
            return num
        elif g - score < s*p:
            if (g-score) % s == 0:
                num += (g-score) // s
            else:
                num += (g-score) // s +1
            return num
        else:
            score += s * p_list[i] + c
            num += p


def bornus():
    c_dct = {}
    for i in range(d):
        c_dct[str(i)] = c_list[i] / p_list[i]

    score = 0
    num = 0
    for k, v in sorted(c_dct.items(), key=lambda x: -x[1]):
        i = int(k)
        s = 100 * (i + 1)
        p = p_list[i]
        c = c_list[i]
        if score + s*p + c < g:
            score += s*p + c
            num += p
            continue
        elif score + s*p + c == g:
            num += p
            return num
        elif g - score < s*p:
            if (g-score) % s == 0:
                num += (g-score) // s
            else:
                num += (g-score) // s +1
            return num
        else:
            score += s * p + c
            num += p




ans_a = greedy()
ans_b = bornus()
print(min(ans_a, ans_b))

Submission status: Runtime Error

Solution code:
d, g = [int(i) for i in input().split()]
p_list = []
c_list = []
for i in range(d):
    p, c = [int(j) for j in input().split()]
    p_list.append(p)
    c_list.append(c)


def greedy():
    score = 0
    num = 0
    for i in range(d)[::-1]:
        s = 100 * (i+1)
        c = c_list[i]
        p = p_list[i]
        if score + s*p_list[i] + c < g:
            score += s*p_list[i] + c
            num += p
            continue
        elif score + s*p_list[i] + c == g:
            num += p
            return num
        elif g - score < s*p:
            if (g-score) % s == 0:
                num += (g-score) // s
            else:
                num += (g-score) // s +1
            return num
        else:
            score += s * p_list[i] + c
            num += p


def bornus():
    c_dct = {}
    for i in range(d):
        c_dct[str(i)] = (c_list[i] + 100*(i+1)*p_list[i]) / p_list[i]

    score = 0
    num = 0
    for k, v in sorted(c_dct.items(), key=lambda x: -x[1]):
        i = int(k)
        s = 100 * (i + 1)
        p = p_list[i]
        c = c_list[i]

        if score + s*p + c < g:
            score += s*p + c
            num += p
            continue
        elif score + s*p + c == g:
            num += p
            return num
        elif g - score < s*p:
            if (g-score) % s == 0:
                num += (g-score) // s
            else:
                num += (g-score) // s +1
            return num
        else:
            score += s * p + c
            num += p




ans_a = greedy()
ans_b = bornus()
print(min(ans_a, ans_b))

Submission status: Runtime Error

Solution code:
d, g = [int(i) for i in input().split()]
p_list = []
c_list = []
for i in range(d):
    p, c = [int(j) for j in input().split()]
    p_list.append(p)
    c_list.append(c)


def greedy():
    score = 0
    num = 0
    for i in range(d)[::-1]:
        s = 100 * (i+1)
        c = c_list[i]
        p = p_list[i]
        if score + s*p_list[i] + c < g:
            score += s*p_list[i] + c
            num += p
            continue
        elif score + s*p_list[i] + c == g:
            num += p
            return num
        elif g - score < s*p:
            if (g-score) % s == 0:
                num += (g-score) // s
            else:
                num += (g-score) // s +1
            return num
        else:
            score += s * p_list[i] + c
            num += p


def bornus():
    c_dct = {}
    for i in range(d):
        c_dct[str(i)] = c_list[i]

    score = 0
    num = 0
    for k, v in sorted(c_dct.items(), key=lambda x: -x[1]):
        i = int(k)
        s = 100 * (i + 1)
        p = p_list[i]
        c = c_list[i]

        if score + s*p + c < g:
            score += s*p + c
            num += p
            continue
        elif score + s*p + c == g:
            num += p
            return num
        elif g - score < s*p:
            if (g-score) % s == 0:
                num += (g-score) // s
            else:
                num += (g-score) // s +1
            return num
        else:
            score += s * p + c
            num += p




ans_a = greedy()
ans_b = bornus()
print(min(ans_a, ans_b))

Submission status: Runtime Error

Solution code:
cases = int(input())
for i in range (cases):

Submission status: Runtime Error

Solution code:
D, G = [int(s) for s in input().split()]
pcs = [[int(s) for s in input().split()] for _ in range(D)]
 
def calc(pcs, D, G):
    if G <= 0:
        return 0
 
    t = G // (D * 100)
    
    if t < pcs[D - 1][0]:
        if D == 1:
            return t
        else:
            return min(t, calc(pcs, D - 1, G))
    else:
        nG = G - (pcs[D - 1][0] * D * 100) - pcs[D - 1][1]
        b = pcs[D - 1][0] + calc(pcs, D - 1, nG)
        return min(b, calc(pcs, D - 1, G))
 
print(calc(pcs, D, G))