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:
S = input()
L = len(S)
Q = 10**9 + 7
anum = [ 0 for _ in range(L+1)]
#bnum = [ 0 for _ in range(L+1)]
cnum = [ 0 for _ in range(L+1)]
hnum = [ 0 for _ in range(L+1)]
for i in range(1,L+1):
    if S[i-1] == 'A':
        anum[i] = anum[i-1] + 1
#        bnum[i] = bnum[i-1]
        cnum[i] = cnum[i-1]
        hnum[i] = hnum[i-1]
    elif S[i-1] == 'B':
        anum[i] = anum[i-1]
#        bnum[i] = bnum[i-1] + 1
        cnum[i] = cnum[i-1]
        hnum[i] = hnum[i-1]
    elif S[i-1] == 'C':
        anum[i] = anum[i-1]
#        bnum[i] = bnum[i-1]
        cnum[i] = cnum[i-1] + 1
        hnum[i] = hnum[i-1]
    else:
        anum[i] = anum[i-1]
#        bnum[i] = bnum[i-1]
        cnum[i] = cnum[i-1]
        hnum[i] = hnum[i-1] + 1

ans = 0
czen = cnum[L]
hzen = hnum[L] 
for i in range(1,L+1):
    if S[i-1] == 'B' or S[i-1] == '?':
        A = (anum[i-1]*(3**hnum[i-1]) + hnum[i-1]*(2**(hnum[i-1]-1)))%Q
        C = ((czen - cnum[i])*(3**(hzen - hnum[i])) + (hzen - hnum[i])*(2**(hzen - hnum[i]-1)))%Q
        ans = (ans + A*C)%Q
print(int(ans))

Submission status: Wrong Answer

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[index] > p[i]):
                    index = i
                    best = pans[i]
        g -= ans[index]
        tmp += p[index]
        ans[index] = 0

print(pre + tmp)

Submission status: Wrong Answer

Solution code:
import sys
import os
import numpy as np
import re

def point(i, p):
    return (i+1)*100*p

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

li = np.array(li)

remain = G
cnt = 0
while True:
    maxi = np.argmax(li[:, 2])
    maxp = np.max(li[maxi, 2])
    maxj = np.argmax(li[:, 3])
    
    if remain > maxp:
        remain -= li[maxj, 2]
        cnt += li[maxj, 0]
        li[maxj, :] = 0

    else:
        for i in range(li.shape[0] - 1, -1, -1):
            if li[i, 0] > 0:
                cnt += int(remain / ((i+1)*100))
                print(int(cnt))
                sys.exit(0)

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:
D,G=map(int,input().split())
data=[]
for i in range(1,D+1):
    li = list(map(int,input().split()))
    li.insert(0,i*100)
    li.append(li[0]*li[1]+li[2])
    data.append(li)
    
data.sort(key=lambda x:x[3]/x[1])
maxpoint=0
while True:
    if data[-1][0]*data[-1][1] >= G:
        if G%data[-1][0]: maxsolve = G//data[-1][0]+1
        else: maxsolve = G//data[-1][0]
        nomax=[]
        for li in data:
            if li[3] >= G: nomax.append(li[1])
        maxpoint+=min(maxsolve,min(nomax))
        break
    elif data[-1][3] >= G:
        maxpoint+=data[-1][1]
        break
    else:
        maxpoint += data[-1][1]
        G -= data[-1][3]
        del data[-1]

print(maxpoint)

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
    res = float("inf")
    for i in sorted(list(P - comped), reverse=True):
        res_ = int(math.floor(norm / (100 * i)))
        if res_ <= p[i]:
            res = min(res, res_)
    return res


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

print(ans)

Submission status: Wrong Answer

Solution code:
D,G=map(int,input().split())
data=[]
for i in range(1,D+1):
    li = list(map(int,input().split()))
    li.insert(0,i*100)
    li.append(li[0]*li[1]+li[2])
    data.append(li)
    
data.sort(key=lambda x:x[3]/x[0])
maxpoint=0
while True:
    if data[-1][0]*data[-1][1] >= G:
        if G%data[-1][0]: maxsolve = G//data[-1][0]+1
        else: maxsolve = G//data[-1][0]
        nomax=[]
        for li in data:
            if li[3] >= G: nomax.append(li[1])
        maxpoint+=min(maxsolve,min(nomax))
        break
    elif data[-1][3] >= G:
        maxpoint+=data[-1][1]
        break
    else:
        maxpoint += data[-1][1]
        G -= data[-1][3]
        del data[-1]

print(maxpoint)

Submission status: Wrong Answer

Solution code:
print(7)

Submission status: Wrong Answer

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

p = []
c = []
for _ in range(D):
    p_, c_ = map(int, input().split())
    p.append(p_)
    c.append(c_)


def dp(g, used_index, mincount):
    new_used_index = copy.deepcopy(used_index)
    for index in reversed(range(D)):
        if index in used_index:
            continue
        point = (index+1) * 100

        if point * p[index] > g:
            #`kosuu
            count = int(math.floor(g / point))
            if mincount > count:
                mincount = count


        elif mincount <= p[index]:
            continue

        elif point * p[index] + c[index] > g:
            new_used_index.append(index)
            count = p[index]
            if mincount > count:
                mincount = count
        else:
            new_g = g - (point * p[index] + c[index])
            new_used_index.append(index)
            count = dp(new_g, new_used_index, mincount) + p[index]
            if mincount > count:
                mincount = count

    return mincount

ret = dp(G,[], 100*10)
print(ret)

Submission status: Wrong Answer

Solution code:
print(6)

Submission status: Wrong Answer

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

#prob_num = [3,5]
#comp = [500,800]

prob_num = []
comp = []

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

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]
    res -= temp_min[choice]
    prob_num[choice] -= req_prob[choice]
    
#    print(ans,res)
    
print(ans)

Submission status: Wrong Answer

Solution code:
print(5)

Submission status: Wrong Answer

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

pc = []
for i in range(D):
    pc.append(list(map(int,input().split())))
    
    
DD = []
for i in range(D):
    DD.append(pc[i][0])
    
mad = max(DD)
count = 0
    
sume = []
for j in range(D):
    sume.append((pc[j][0] * 100 * (j+1) + pc[j][1]))#/pc[j][0])
    
ex = []
for j in range(D):
    ex.append((pc[j][0] * 100 * (j+1) + pc[j][1])/pc[j][0])



while G > sume[ex.index(max(ex))]:
    G = G - sume[ex.index(max(ex))]
    count = count + pc[ex.index(max(ex))][0]
    ex[ex.index(max(ex))] = 0

low = []
for i in range(D):
    low.append([0]*mad)
    
for i in range(D):
    for j in range(mad):
        low[i][j] = ((j <= DD[i]-1) * 100 * (j+1) * (i+1) + (j == DD[i]-1) * pc[i][1]) * (ex[i] > 0)


ans = [1000000000]*D #i
for i in range(D):
    for j in range(mad):
        if low[i][j] >= G:
            ans[i] = j
            break

print(min(ans)+1+count)

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
    raise Exception


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

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[0]))
        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:
import math

D, G =map(int,input().split())
a =[]
for i in range(D):
    a.append([int(x) for x in input().split()])
bonus=G
nobonus=G

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
nobonuscount+=math.ceil(nobonus/((j)*100))
print (nobonuscount)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from math import ceil

D, G = [int(t) for t in input().split()]
p = []
c = []
for i in range(D):
    p_, c_ = [int(t) for t in input().split()]
    p.append(p_)
    c.append(c_)

cache = {}

def minsolve(G, p, c, i):
    """100i点以下の問題だけでGを達成する最小問題数"""
    if i <= 0:
        return float('inf')
    n = min(ceil(G / (100 * i)), p[i-1])
    m = [(p[j-1], j) for j in range(1, i)
            if p[j-1] <= n and \
               100 * i * p[j-1] < 100 * j * p[j-1] + c[j-1]]
    if len(m) > 0:
        m, j = min(m)
        n -= m
    s = 100 * i * n
    if n == p[i-1]:
        s += c[i-1]
    if s >= G:
        return n
    else:
        return n + minsolve(G - s, p, c, i-1)

m = min(minsolve(G, p, c, i) for i in range(1, D+1))
print(m)

Submission status: Wrong Answer

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

pc = []
for i in range(D):
    pc.append(list(map(int,input().split())))
    
    
DD = []
for i in range(D):
    DD.append(pc[i][0])
    
mad = max(DD)
count = 0
    
sume = []
for j in range(D):
    sume.append((pc[j][0] * 100 * (j+1) + pc[j][1]))#/pc[j][0])
    
ex = []
for j in range(D):
    ex.append((pc[j][0] * 100 * (j+1) + pc[j][1])/pc[j][0])



while G > sume[ex.index(max(ex))]:
    G = G - sume[ex.index(max(ex))]
    count = count + pc[ex.index(max(ex))][0]
    ex[ex.index(max(ex))] = 0

low = []
for i in range(D):
    low.append([0]*mad)
    
for i in range(D):
    for j in range(mad):
        low[i][j] = ((j <= DD[i]-1) * 100 * (j+1) * (i+1) + (j == DD[i]-1) * pc[i][1]) * (ex[i] > 0)


ans = [1000]*D #i
for i in range(D):
    for j in range(mad):
        if low[i][j] >= G:
            ans[i] = j
            break

print(min(ans)+1+count)

Submission status: Wrong Answer

Solution code:
class Solution:

    def check(self):
        n, target = map(int, (input().split()))
        value = {}
        test = {}
        for i in range(n):
            a, b = map(int, (input().split()))
            # value.append((b + a*100 * (i + 1)) / a)
            # value[(b + a * 100 * (i + 1)) / a] = a
            value[a] = [b, i + 1]
            total = (b + a * 100 * (i + 1))
            test[a] = total / a if total < target else 100 * (i + 1)

        alist = sorted(test, key=lambda x: test[x], reverse=True)
        ncount = 0
        for key in alist:
            val = value[key]

            if key * 100 * val[1] + val[0] == target:
                ncount += key
                return ncount
            elif key * 100 * val[1] + val[0] > target:

                return ncount + target // (val[1] * 100)
            else:
                ncount += key
                target -= key * 100 * val[1] + val[0]
        return ncount


print(Solution().check())

Submission status: Wrong Answer

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

#prob_num = [3,5]
#comp = [500,800]

prob_num = []
comp = []

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

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(100000)
        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]
    res -= temp_min[choice]
    prob_num[choice] = 0
    
#    print(ans,res)
    
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque

def solve(d, g, pcs):
    queue = deque()
    queue.append((0, d, g, pcs, 0))
    while True:
        count, d, g, pcs, n = queue.popleft()
        #print(count, d, g, pcs)
        if g <= 0:
            return count
        if n > 0:
            p, c = pcs[n - 1]
            l = pcs.copy()
            if p == 1:
                l = pcs.copy()
                l[n - 1] = (0, 0)
                queue.append((count + 1, d, g - c - 100 * n, l, 0))
            elif p > 1:
                l = pcs.copy()
                l[n - 1] = (p - 1, c)
                queue.append((count + 1, d, g - 100 * n, l, n))
        else:
            pmin = float("Inf")
            for i in range(d, 0, -1):
                p, c = pcs[i - 1]
                if p == 0 or pmin < p:
                    continue
                pmin = p
                if p == 1:
                    l = pcs.copy()
                    l[i - 1] = (0, 0)
                    queue.append((count + 1, d, g - c - 100 * i, l, 0))
                else:
                    l = pcs.copy()
                    l[i - 1] = (p - 1, c)
                    queue.append((count + 1, d, g - 100 * i, l, i))


if __name__ == "__main__":
    d, g = map(int, input().split())
    pcs = [tuple(int(s) for s in input().split()) for _ in range(d)]
    print(solve(d, g, pcs))

Submission status: Wrong Answer

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

avg_points = [(100 * (i+1) * listPC[i][0] + listPC[i][1])/(listPC[i][0]) for i in range(D)]

count = 0
while G > 0:
    m = avg_points.index(max(avg_points))
    for i in range(listPC[m][0]):
        G -= 100 * (m + 1)
        count += 1
        
        if i == listPC[m][0] - 1:
            G -= listPC[m][1]
        
        if G <= 0:
            break
    
    avg_points[m] = 0

print(count)

Submission status: Wrong Answer

Solution code:
D,G=map(int,input().split())
data=[]
for i in range(1,D+1):
    li = list(map(int,input().split()))
    li.insert(0,i*100)
    li.append(li[0]*li[1]+li[2])
    data.append(li)
    
maxpoint=0
while True:
    if data[-1][0]*data[-1][1] >= G:
        if G%data[-1][0]: maxsolve = G//data[-1][0]+1
        else: maxsolve = G//data[-1][0]
        nomax=[]
        for li in data:
            if li[3] >= G: nomax.append(li[1])
        maxpoint+=min(maxsolve,min(nomax))
        break
    elif data[-1][3] >= G:
        maxpoint+=data[-1][1]
        break
    else:
        maxpoint += data[-1][1]
        G -= data[-1][3]
        del data[-1]

print(maxpoint)

Submission status: Wrong Answer

Solution code:
def can(d,g,p,c, maxPick):
	# n問解いてg点獲得できるか？

	# パーフェクトを狙う問題の組み合わせを生成
	for i in range(0, 2**(d-1)):

		# このパーフェクトのとり方で条件が達成できるか？
		point = 0
		picked = 0
		for j in range(0, d-1):
			if i & (2**j) != 0:
				point += (j+1) * 100 * p[j] + c[j]
				picked += p[j]

		if picked > maxPick:
			#print (i, " is un")
			continue
		#print ("i", i , "picked", picked, "point", point)

		# 残り個数分だけ、点数の高い問題をとる
		t = d-1
		while(picked < maxPick):
			if i & (2**t) != 0:
				t -= 1
				continue
			pick = min(p[t], (maxPick - picked))
			picked += pick
			point += (t+1)*100 * pick
			if pick == p[t]:
				point += c[t]
			#print ("t", t, "pick", pick, "picked", picked, "point", point)
			t -= 1

		if point >= g:
			return True
		else:
			print (point)
	return False


def bin(d,g,p,c):
	left = 1
	right = sum(p)
	while left != right:
		cen = (left + right) // 2
		#print ("left", left, "cen", cen, "right", right)
		if(can(d,g,p,c,cen)):
			right = cen
		else:
			left = cen + 1
	return right


s = input().split(" ")
d = int(s[0])
g = int(s[1])

p = []
c = []

for i in range(0, d):
	s = input().split(" ")
	p.append(int(s[0]))
	c.append(int(s[1]))

print(bin(d,g,p,c))

Submission status: Wrong Answer

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

p = []

for i in range(d):
    p.append(list(map(int,input().split())))

nums = []

from itertools import permutations
from math import ceil


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

num0 = 0
flag = True
while flag:
    j = scores.index(max(scores))
    if sum(scores[:j]+scores[j+1:]) < g:
        num0 += p[j][0]
        p[j] = (0,0)
        g -= scores[j]
        scores[j] = 0
    else:
        flag = False

ind = []
for i in range(d):
    if p[i] != (0,0):
        ind.append(i)

for perm in permutations(ind):
    s = g
    num = num0
    for i in range(len(ind)):
        j = perm[i]
        if s > 100*(j+1)*p[j][0] + p[j][1]:
            s -= 100*(j+1)*p[j][0] + p[j][1]
            num += p[j][0]
        else:
            if s <= 100*(j+1)*(p[j][0] - 1):
                num += ceil(s / (100*(j+1)))
            else:
                num += p[j][0]
            s=0
        if s<=0:
            break
    nums.append(num)

print(min(nums))

Submission status: Wrong Answer

Solution code:
def can(d,g,p,c, maxPick):
	# n問解いてg点獲得できるか？

	# パーフェクトを狙う問題の組み合わせを生成
	for i in range(0, 2**(d-1)):

		# このパーフェクトのとり方で条件が達成できるか？
		point = 0
		picked = 0
		for j in range(0, d-1):
			if i & (2**j) != 0:
				point += (j+1) * 100 * p[j] + c[j]
				picked += p[j]

		if picked > maxPick:
			print (i, " is un")
			continue
		print ("i", i , "picked", picked, "point", point)

		# 残り個数分だけ、点数の高い問題をとる
		t = d-1
		while(picked < maxPick):
			if i & (2**t) != 0:
				t -= 1
				continue
			pick = min(p[t], (maxPick - picked))
			picked += pick
			point += (t+1)*100 * pick
			if pick == p[t]:
				point += c[t]
			print ("t", t, "pick", pick, "picked", picked, "point", point)
			t -= 1

		if point >= g:
			return True
		else:
			print (point)
	return False


def bin(d,g,p,c):
	left = 1
	right = sum(p)
	while left != right:
		cen = (left + right) // 2
		print ("left", left, "cen", cen, "right", right)
		if(can(d,g,p,c,cen)):
			right = cen
		else:
			left = cen + 1
	return right


s = input().split(" ")
d = int(s[0])
g = int(s[1])

p = []
c = []

for i in range(0, d):
	s = input().split(" ")
	p.append(int(s[0]))
	c.append(int(s[1]))

print(bin(d,g,p,c))

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 i in range(2**d):
    s=''.join((['0']*d+list(str(bin(i))[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
print(r)

Submission status: Wrong Answer

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
    if D == 0:
        return 100000000
 
    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]
        t = pcs[D - 1][0] + calc(pcs, D - 1, nG)
        for n in reversed(range(pcs[D - 1][0])):
            if t == min(t, n + calc(pcs, D - 1, G - n * D * 100)):
                break
            t = min(t, n + calc(pcs, D - 1, G - n * D * 100))
        return t
 
print(calc(pcs, D, G))

Submission status: Wrong Answer

Solution code:
D,G=map(int,input().split())
data=[]
for i in range(1,D+1):
    li = list(map(int,input().split()))
    li.insert(0,i*100)
    li.append(li[0]*li[1]+li[2])
    data.append(li)
    
maxpoint=0
while True:
    if data[-1][0]*data[-1][1] >= G:
        if G%data[-1][0]:maxsolve = G//data[-1][0]+1
        else: maxsolve = G//data[-1][0]
        nomax=[]
        for li in data:
            if li[3]>G:nomax.append(li[1])
        maxpoint+=min(maxsolve,min(nomax))
        break
    elif data[-1][3] >= G:
        maxpoint+=data[-1][1]
        break
    else:
        maxpoint+=data[-1][1]
        G-=data[-1][3]
        del data[-1]

print(maxpoint)

Submission status: Wrong Answer

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])
        g -= ans[pans.index(max(pans))]
        tmp += p[pans.index(max(pans))]
        ans[pans.index(max(pans))] = 0

print(pre + tmp)

Submission status: Wrong Answer

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

p = []

for i in range(d):
    p.append(list(map(int,input().split())))

nums = []

from itertools import permutations
from math import ceil


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

flag = True
while flag:
    j = scores.index(max(scores))
    if sum(scores[:j]+scores[j+1:]) < g:
        p[j] = (0,0)
        g -= scores[j]
        scores[j] = 0
    else:
        flag = False

ind = []
for i in range(d):
    if p[i] != (0,0):
        ind.append(i)

for perm in permutations(ind):
    s = g
    num = 0
    for i in range(len(ind)):
        j = perm[i]
        if s > 100*(j+1)*p[j][0] + p[j][1]:
            s -= 100*(j+1)*p[j][0] + p[j][1]
            num += p[j][0]
        else:
            if s <= 100*(j+1)*(p[j][0] - 1):
                num += ceil(s / (100*(j+1)))
            else:
                num += p[j][0]
            s=0
        if s<=0:
            break
    nums.append(num)

print(min(nums))

Submission status: Wrong Answer

Solution code:
d, g = map(int, input().split())
p = [0 for i in range(d)]
c = [0 for i in range(d)]
ans = 0
min_p = 101
min_p_i = 10
for i in range(d):
    p[i], c[i] = map(int, input().split())
    if min_p >= p[i]:
        min_p = p[i]
        min_p_i = i
tmp = 0
unused_i = [i for i in range(d)]
while g > tmp:
    score = [0 for i in range(d)]
    max_score = -1
    max_score_i = -1
    for i in range(d):
        if min_p_i == i:
            score[i] = 100*(i+1)*min_p+c[i]
        else:
            score[i] = 100*(i+1)*min_p
        if max_score < score[i]:
            max_score = score[i]
            max_score_i = i

    min_n = -(-g // (100*(unused_i[-1]+1)))

    if min_n < min_p and min_n <= p[unused_i[-1]]:
        p[unused_i[-1]] -= min_n
        ans += min_n
        tmp += 100*(unused_i[-1]+1)*min_n
        if p[unused_i[-1]] == 0:
            tmp += c[unused_i[-1]]
            unused_i.remove(unused_i[-1])
    elif max_score >= g:
    # else:
        ans += min_p
        tmp += max_score
        p[max_score_i] -= min_p
        if p[max_score_i] == 0:
            unused_i.remove(max_score_i)
    else:
        for j in range(p[unused_i[-1]]):
            ans += 1
            tmp += 100*(unused_i[-1]+1)
            if tmp >= g:
                loopFlag = False
                break
        tmp += c[unused_i[-1]]
        p[unused_i[-1]] = 0
        unused_i.remove(unused_i[-1])
print(ans)

Submission status: Wrong Answer

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

p = []
c = []
for _ in range(D):
    p_, c_ = map(int, input().split())
    p.append(p_)
    c.append(c_)


def dp(g, used_index, mincount):
    for index in reversed(range(D)):
        if index in used_index:
            continue
        point = (index+1) * 100

        if point * p[index] > g:
            #`kosuu
            count = int(math.floor(g / point))
            if mincount > count:
                mincount = count


        elif mincount <= p[index]:
            continue

        elif point * p[index] + c[index] > g:
            count = p[index]
            if mincount > count:
                mincount = count
        else:
            new_g = g - (point * p[index] + c[index])
            new_used_index = copy.deepcopy(used_index)
            new_used_index.append(index)
            count = dp(new_g, new_used_index, mincount) + p[index]
            if mincount > count:
                mincount = count

    return mincount

ret = dp(G,[], 100*10)
print(ret)