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:
n, g = map(int, input().split())
List = [list(map(int, input().split())) for i in range(n)]

ans = 0
a = 0
res = 0

max_score = [(i+1)*100*List[i][0]+List[i][1] for i in range(n-1, -1, -1)] #全て答えたときのスコアを算出(逆順)
score = [(i+1)*100 for i in range(n-1, -1, -1)] #各レベルの点数を算出しておく(逆順)
howmany = [List[i][0] for i in range(n-1, -1, -1)]

while(ans + max_score[a] <= g):
    ans += max_score[a]
    a += 1

for i in range(a):
    res += howmany[i]
    
rest = g - ans
x = -(-rest // score[a])
    
#print(max_score)
#print(score)
#print(howmany)
#print(res)
print(res + x)

Submission status: Runtime Error

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

ans = 0
a = 0
res = 0

max_score = [(i+1)*100*List[i][0]+List[i][1] for i in range(n-1, -1, -1)] #全て答えたときのスコアを算出
score = [(i+1)*100 for i in range(n-1, -1, -1)] #各レベルの点数を算出しておく

while(ans + max_score[a] <= g):
    ans += max_score[a]
    a += 1

for i in range(a):
    res += List[n - a][0]
    
rest = g - ans
x = -(-rest // score[a])
    
print(res + x)

Submission status: Runtime Error

Solution code:
n, g = map(int, input().split())
List = [list(map(int, input().split())) for i in rage(n)]

ans = 0
a = 0
res = 0

max_score = [(i+1)*100*List[i][0]+List[i][1] for i in range(n-1, -1, -1)] #全て答えたときのスコアを算出
score = [(i+1)*100 for i in range(n-1, -1, -1)] #各レベルの点数を算出しておく

while(ans + max_score[a] <= g):
    ans += max_score[a]
    a += 1

for i in range(a):
    res += List[n - a][0]
    
rest = g - ans
x = -(-rest // score[a])
    
print(res + x)

Submission status: Runtime Error

Solution code:
# 小さいのでメモ化再帰でいけるか？
# （[ここまでの回答数, ここまでの点数]みたいなやつ）
# んーーーーーー？？？？ RE*1、あとTLEになる。。。
# REはどうせ再帰の制限
import sys

sys.setrecursionlimit(10 ** 8)

d, g = map(int, input().split())
memo = {}
points, bonus = [], []
for _ in range(d):
    p, c = map(int, input().split())
    points.append(p)
    bonus.append(c)


def f(c, p):
    if (c, p) in memo:
        return memo[(c, p)]
    if p >= g:
        return c
    ret = 10 ** 10
    for i in range(d):
        if points[i] == 1:
            points[i] = 0
            ret = min(ret, f(c + 1, p + (i + 1) * 100 + bonus[i]))
            points[i] = 1
        elif points[i] > 1:
            points[i] -= 1
            ret = min(ret, f(c + 1, p + (i + 1) * 100))
            points[i] += 1
        else:
            print(3 / 0)
            continue
    memo[(c, p)] = ret
    return ret


print(f(0, 0))

Submission status: Runtime Error

Solution code:
# 小さいのでメモ化再帰でいけるか？
# （[ここまでの回答数, ここまでの点数]みたいなやつ）
# んーーーーーー？？？？ RE*1、あとTLEになる。。。
# REはどうせ再帰の制限
import sys
sys.setrecursionlimit(10**10)

d, g = map(int, input().split())
memo = {}
points, bonus = [], []
for _ in range(d):
    p, c = map(int, input().split())
    points.append(p)
    bonus.append(c)


def f(c, p):
    if (c, p) in memo:
        return memo[(c, p)]
    if p >= g:
        return c
    ret = 10 ** 10
    for i in range(d):
        if points[i] == 1:
            points[i] = 0
            ret = min(ret, f(c + 1, p + (i + 1) * 100 + bonus[i]))
            points[i] = 1
        elif points[i] > 1:
            points[i] -= 1
            ret = min(ret, f(c + 1, p + (i + 1) * 100))
            points[i] += 1
        else:
            continue
    memo[(c, p)] = ret
    return ret


print(f(0, 0))

Submission status: Runtime Error

Solution code:
# 小さいのでメモ化再帰でいけるか？
# （[ここまでの回答数, ここまでの点数]みたいなやつ）
d, g = map(int, input().split())
memo = {}
points, bonus = [], []
for _ in range(d):
    p, c = map(int, input().split())
    points.append(p)
    bonus.append(c)


def f(c, p):
    if (c, p) in memo:
        return memo[(c, p)]
    if p >= g:
        return c
    ret = 10 ** 10
    for i in range(d):
        if points[i] == 1:
            points[i] = 0
            ret = min(ret, f(c + 1, p + (i + 1) * 100 + bonus[i]))
            points[i] = 1
        elif points[i] > 1:
            points[i] -= 1
            ret = min(ret, f(c + 1, p + (i + 1) * 100))
            points[i] += 1
        else:
            continue
    memo[(c, p)] = ret
    return ret


print(f(0, 0))

Submission status: Runtime Error

Solution code:
N = input().split()
N = [int(i) for i in N]
pi = [0 for i in range(N[0])]
ci = [0 for i in range(N[0])]
for i in range(N[0]):
    buf = input().split()
    pi[i] = int(buf[0])
    ci[i] = int(buf[1])

num_min = 10*100
G_new = N[1]

flag= [0 for i in range(N[0])]
for i in range(0, pow(2, N[0])):
    G_new = N[1]
    count = 0
    #print(bin(i))
    for j in range(N[0]):
        flag[j] = (i>>j & 1)
        if(flag[j]==1):
            G_new -= ci[j]
            G_new -= 100*(j+1)*pi[j]
            count += pi[j]
    #print(flag)

    if(G_new<=0):
        #print(i, flag)
        if(count < num_min):
            #print(count)
            num_min = count
            #print(count)
    else:
        for j in range(N[0]):
            if((flag[N[0]-1-j])==0):
                #print(i, flag, N[0]-1-j, G_new, pi[N[0]-1-j], count, -(-G_new//(100*(N[0]-j)))   )
                if(G_new - 100*(N[0]-j)*pi[N[0]-1-j] < 0):
                    count += -(-G_new//(100*(N[0]-j)))
                    if(count < num_min):
                       # print(count)
                        num_min = count
                		break

    
print(num_min)

Submission status: Runtime Error

Solution code:
mport sys
sys.setrecursionlimit(200000)
 
def dfs(i, num, totalValue):
	if i <= 0:
		return sys.maxsize
  
	if num > NUMS[i-1][0]:
		return dfs(i - 1, 1, totalValue)
 
	value = NUMS[i-1][2] *100 + (NUMS[i-1][1] if num == NUMS[i-1][0] else 0)
	if totalValue + value < G:
		return 1 + dfs(i, num + 1, totalValue + value)
	if totalValue + value >= G:
		return 1
 
def expectValue(num, i, bonus):
  return (num * i * 100.0 + bonus) / num
      
D, G = map(int, input().split())
if (D == 0 or G == 0):
	print(0)
	sys.exit()
 
NUMS = [list(map(int, input().split())) for _ in range(D)]
l = [((num, bonus, i + 1), expectValue(num, i + 1, bonus)) for i, (num, bonus) in enumerate(NUMS)]
NUMS = [x[0] for x in sorted(l, key=lambda x: x[1])]
#print([dfs(x, 1, 0) for x in reversed(range(1, D+1))])
print(min([dfs(x, 1, 0) for x in reversed(range(1, D+1))]))

Submission status: Runtime Error

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


# リスト生成
# [[0, 1, 2, 3], [0, 1, 2, 3, 4, 5]]
lis = [[] for i in range(len(p))]
# print(lis)
for i in range(len(p)):
    for j in range(p[i]+1):
        lis[i].append(j)
# print(lis)

# -------------------------------------------------------------------------
# https://youkoso-guest.hatenadiary.org/entry/20081212/1229089595
# 直積作成
from functools import reduce

# 直積を求める関数
def product(lists):
    return reduce(
        lambda prod, list: [x + [y] for x in prod for y in list],
        lists, [[]])
# -------------------------------------------------------------------------

chokuseki = product(lis)
# print(chokuseki)

def keisan(lis):
    global p, c, D, G
    goukei = 0
    for i in range(D):
        goukei += (i+1) * 100 * lis[i]
        if lis[i] == p[i]:
            goukei += c[i]
#         print(goukei)
    
    if goukei >= G:
        return(sum(lis))

scores = []
for x in chokuseki:
    if keisan(x) != None:
        scores.append(keisan(x))

print(min(scores))

Submission status: Runtime Error

Solution code:
D, G = map(int, input().split())
for _ in range(D):
    p, c = map(int, input().split())


# リスト生成
# [[0, 1, 2, 3], [0, 1, 2, 3, 4, 5]]
lis = [[] for i in range(len(p))]
# print(lis)
for i in range(len(p)):
    for j in range(p[i]+1):
        lis[i].append(j)
# print(lis)

# -------------------------------------------------------------------------
# https://youkoso-guest.hatenadiary.org/entry/20081212/1229089595
# 直積作成
from functools import reduce

# 直積を求める関数
def product(lists):
    return reduce(
        lambda prod, list: [x + [y] for x in prod for y in list],
        lists, [[]])
# -------------------------------------------------------------------------

chokuseki = product(lis)
# print(chokuseki)

def keisan(lis):
    global p, c, D, G
    goukei = 0
    for i in range(D):
        goukei += (i+1) * 100 * lis[i]
        if lis[i] == p[i]:
            goukei += c[i]
#         print(goukei)
    
    if goukei >= G:
        return(sum(lis))

scores = []
for x in chokuseki:
    if keisan(x) != None:
        scores.append(keisan(x))

print(min(scores))

Submission status: Runtime Error

Solution code:
using System;

namespace kozaiyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            
            int A = 100;
            int score = 0;
            int selected = 0;

            string[] input = Console.ReadLine().Split(' ');
            int D = int.Parse(input[0]);
            int G = int.Parse(input[1]);

            int[] P = new int[D];
            int[] C = new int[D];

            for (int i = 0; i < D; i++)
            {
                string[] subInput = Console.ReadLine().Split(' ');
                P[i] = int.Parse(subInput[0]);
                C[i] = int.Parse(subInput[1]);
            }

            for (int i = 0; i < D; i++)
            {
                int subScore = P[i] * (i * 100);
                subScore += C[i];

                if (score < subScore && A > P[i])
                {
                    A = P[i];
                    score = subScore;
                    selected = i;
                }
            }

            if (score < G)
            {
                for (int i = D - 1; i <= 0; i--)
                {
                    if (i == selected)
                    {
                        continue;
                    }

                    if (score < G)
                    {
                        for (int j = 1; j <= P[i]; j++)
                        {
                            if (score < G)
                            {
                                score += (i * 100);
                                A += 1;
                                if (j == P[i])
                                {
                                    score += C[i];
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            Console.WriteLine(A);
        }
    }
}

Submission status: Runtime Error

Solution code:
import sys

def dfs(i, num, totalValue):
	if i -1 < 0:
		return 10000000000
  
	if num > NUMS[i-1][0]:
		return dfs(i - 1, 1, totalValue)

	value = NUMS[i-1][2] *100 + (NUMS[i-1][1] if num == NUMS[i-1][0] else 0)
	if totalValue + value < G:
		return 1 + dfs(i, num + 1, totalValue + value)
	if totalValue + value >= G:
		return 1

def expectation(num, i, bonus):
  return (num * i * 100 + bonus) / num
      
D, G = map(int, input().split())
if (D == 0 or G == 0):
	print(0)
	sys.exit()

NUMS = [list(map(int, input().split())) for _ in range(D)]
l = [((num, bonus, i + 1), expectation(num, i + 1, bonus)) for i, (num, bonus) in enumerate(NUMS)]
NUMS = [x[0] for x in sorted(l, key=lambda x: x[1])]
#print([dfs(x, 1, 0) for x in reversed(range(1, D+1))])
print(min([dfs(x, 1, 0) for x in reversed(range(1, D+1))]))

Submission status: Runtime Error

Solution code:
import sys

def dfs(i, num, totalValue):
	if i <= 0:
		return 10000000000
  
	if num > NUMS[i-1][0]:
		return dfs(i - 1, 1, totalValue)

	value = NUMS[i-1][2] *100 + (NUMS[i-1][1] if num == NUMS[i-1][0] else 0)
	if totalValue + value < G:
		return 1 + dfs(i, num + 1, totalValue + value)
	if totalValue + value >= G:
		return 1

def expectation(num, i, bonus):
  return (num * i * 100 + bonus) / num
      
D, G = map(int, input().split())
if (D == 0 or G == 0):
	print(0)
	sys.exit()

NUMS = [list(map(int, input().split())) for _ in range(D)]
l = [((num, bonus, i + 1), expectation(num, i + 1, bonus)) for i, (num, bonus) in enumerate(NUMS)]
NUMS = [x[0] for x in sorted(l, key=lambda x: x[1])]
#print([dfs(x, 1, 0) for x in reversed(range(1, D+1))])
print(min([dfs(x, 1, 0) for x in reversed(range(1, D+1))]))

Submission status: Runtime Error

Solution code:
import sys

def dfs(i, num, totalValue):
	if i <= 0:
		return 10000000000
  
	if num > NUMS[i-1][0]:
		return dfs(i - 1, 1, totalValue)

	value = i *100 + (NUMS[i-1][1] if num == NUMS[i-1][0] else 0)
	if totalValue + value < G:
		return 1 + dfs(i, num + 1, totalValue + value)
	if totalValue + value >= G:
		return 1

D, G = map(int, input().split())
if (D == 0 or G == 0):
	print(0)
	sys.exit()

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


#print([dfs(x, 1, 0) for x in reversed(range(1, D+1))])
print(min([dfs(x, 1, 0) for x in reversed(range(1, D+1))]))

Submission status: Runtime Error

Solution code:
import sys

def dfs(i, num, totalValue):
	if i <= 0:
		return 100000000
  
	if num > NUMS[i-1][0]:
		return dfs(i - 1, 1, totalValue)

	value = i *100 + (NUMS[i-1][1] if num == NUMS[i-1][0] else 0)
	if totalValue + value < G:
		return 1 + dfs(i, num + 1, totalValue + value)
	if totalValue + value >= G:
		return 1

D, G = map(int, input().split())
if (D == 0 or G == 0):
	print(0)
	sys.exit()

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


#print([dfs(x, 1, 0) for x in reversed(range(1, D+1))])
print(min([dfs(x, 1, 0) for x in reversed(range(1, D+1))]))

Submission status: Runtime Error

Solution code:
import sys

def dfs(i, num, totalValue):
	if i <= 0:
		return 100000000
  
	if num > NUMS[i-1][0]:
		return dfs(i - 1, 1, totalValue)

	value = i *100 + (NUMS[i-1][1] if num == NUMS[i-1][0] else 0)
	if totalValue + value < G:
		return 1 + dfs(i, num + 1, totalValue + value)
	if totalValue + value >= G:
		return 1

D, G = map(int, input().split())
if (G == 0):
	print(0)
	sys.exit()

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


#print([dfs(x, 1, 0) for x in reversed(range(1, D+1))])
print(min([dfs(x, 1, 0) for x in reversed(range(1, D+1))]))

Submission status: Runtime Error

Solution code:
def dfs(i, num, totalValue):
	if i <= 0:
		return 100000000
  
	if num > NUMS[i-1][0]:
		return dfs(i - 1, 1, totalValue)

	value = i *100 + (NUMS[i-1][1] if num == NUMS[i-1][0] else 0)
	if totalValue + value < G:
		return 1 + dfs(i, num + 1, totalValue + value)
	if totalValue + value >= G:
		return 1

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

print(min([dfs(x, 1, 0) for x in reversed(range(1, D+1))]))

Submission status: Runtime Error

Solution code:
import itertools

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

P_list = list(range(D))
cnt = float('inf')

for i in range(D):
	for bonus in itertools.combinations(P_list, i):

		tmp_cnt = 0
		score = 0

		for j in bonus:
			score += PC[j][0] * 100 * (j+1) + PC[j][1]
			tmp_cnt += PC[j][0]

		res_max_p = max([k for k in range(D) if k not in bonus])
		res_score = G - score
		if res_score > 0:
			t = (-res_score//((res_max_p+1)*100)) * (-1) 
			if t < PC[res_max_p][0]:
				tmp_cnt += t
			else:
				continue

		cnt = min(cnt, tmp_cnt)

if cnt == float('inf'):
	cnt = sum([PC[j][0] for j in rnage(D)])

print(cnt)

Submission status: Runtime Error

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


def dfs(i, sum, count, nokori):
    global ans
    if i == D:
        if sum < G:
            use = max(nokori)
            n = min(pc[use-1][0], -(-(G-sum)//(use*100)))
            count += n
            sum += n * use * 100
        if sum >= G:
            ans = min(ans, count)

    else:
        dfs(i+1, sum, count, nokori)
        dfs(i+1, sum+pc[i][0]*(i+1)*100+pc[i][1], count+pc[i][0], nokori-{i+1})


ans = float('inf')

dfs(0, 0, 0, set(range(1, D+1)))
print(ans)

Submission status: Runtime Error

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

L = []

t = 10 ** 9
m = 0

for i in range(1,D + 1):
  p,c = map(int,input().split())
  s = 0
  pc = []
  for j in range(p):
    s += i * 100
    if j == p - 1:
      s += c
      L.append([j + 1,s])
    if s >= G and j + 1 < t:
      t = j + 1
    pc.append([j + 1,s])
  PC.append(pc)

def recur(problems):
　#探索の終了
  if len(problems) == D:
    ans = 10 ** 9
    score = 0
    times = 0
    #全部使用した問題セットの合計点と回答数を記録
    for j in range(D):
      if problems[j] == 1:
        score += L[j][1]
        times += L[j][0]
    #全問全回答の例を除く
    if score >= G:
      ans = min(ans,times)
      return ans
    #残りの数以上となる回答数のうち最小のものが見つかれば更新し
    #全回答の回答数に足す
    else:
      remain = G - score
      if remain <= max([L[i][1] for i in range(D) if problems[i] == 0]):
        for k in range(D):
          if problems[k] == 0:
            for l in range(len(PC[k])):
              if remain <= PC[k][l][1] and ans >= PC[k][l][0]:
                ans = PC[k][l][0]
        ans += times
        return ans
      else:
        return 10 ** 9
  
  else:
    #問題セットを全部使う
    ret1 = recur(problems + [1])
    #使わない
    ret2 = recur(problems + [0])
    
    return min(ret1,ret2)

print(recur([]))

Submission status: Runtime Error

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

L = []

P = [0] * D

t = 10 ** 9
m = 0

for i in range(1,D + 1):
  p,c = map(int,input().split())
  s = 0
  pc = []
  for j in range(p):
    s += i * 100
    if j == p - 1:
      s += c
      L.append([j + 1,s])
    if s >= G and j + 1 < t:
      t = j + 1
    pc.append([j + 1,s])
  PC.append(pc)

def recur(score,times,i,problems):
  if score <= max( [L[i][1] for i in range(D) if P[i] == 0]) and i == 5:
    ans = 10 ** 9
    for j in range(D):
      #使わなかったリストから
      if P[j] == 0:
        #点数のリスト
        for k in range(len(PC[j])):
          #引いた後のスコアを上回る点数のなかから最小値を記録
          if score <= PC[j][k][1] and ans >= PC[j][k][1]:
            ans = PC[j][k][0]
    ans += times
    return ans
  
  elif i == 5:
    return 10 ** 9
  
  else:
    #使う
    ret1 = recur(score - L[i][1],times + L[i][0],i + 1,P[i] + 1)
    #使わない
    ret2 =recur(score,times,i + 1,P[i] + 0)
    
    return min(ret1,ret2)

if t == 10 ** 9:
  print(recur(G,0,0,P))
  
else:
  print(t)

Submission status: Runtime Error

Solution code:
import itertools
import math

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

all = set()
for x in range(0, d):
    all.add(x)

pl = list()
for i in range(0, d):
    p, c = map(int, input().split(" "))
    pl.append((i, p, c))

ans = 100000000
for n in range(0, d + 1):
    for select in itertools.combinations(pl, n):
        full_sum = 0
        full_count = 0
        full_list = set()

        for fp, fn, fc in select:
            full_sum += (fp + 1) * 100 * fn + fc
            full_count += fn
            full_list.add(fp)
        
        if full_sum > g:
            ans = min(ans, full_count)
            # print("full: %s rest: None score: %d ans: %d" % (str(full_list), full_sum, ans))

        else:
            rest = max(all - full_list)
            rest_n, rest_p, rest_c = pl[rest]

            if g - full_sum <= (rest_n + 1) * 100 * (rest_p - 1):
                ans = min(ans, full_count + math.ceil((g - full_sum) / ((rest_n + 1) * 100)))
                # print("full: %s rest: %d score: %d ans: %d" % (str(full_list), rest_n, full_sum + rest_n * (rest_p - 1), ans))
        

print(ans)

Submission status: Runtime Error

Solution code:
D, G = (int(i) for i in input().split())  
PC = [[int(i) for i in input().split()] for i in range(D)] 

max_atmpt = G // (D * 100)
total = 0
ans = 0
count = 0
pc_gain_sorted = []
idx_list = []
for i, (p, c) in enumerate(PC):
  pc_gain_sorted.append((p * (i + 1) * 100 + c, i + 1, p))
pc_gain_sorted.reverse()

for gain, idx, _ in pc_gain_sorted:
  if total + gain <= G:
    total += gain
    idx_list.append(idx) # start from 1
    count += PC[idx - 1][0]
    
for gain, idx, p in pc_gain_sorted:
  if idx not in idx_list:
    break

for i in range(10):
  tmp = []
  for j, (p, c) in enumerate(PC):
    if i + 1 
  	tmp.append((j + 1) * 100 * (i + 1)
  

print(ans + count)

Submission status: Runtime Error

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

for i in range(d):
    p,c = map(int,input().split())
    li.append([p,c])

ans = 10**9
for i in range(1<<d):
    ttl = 0
    cnt = 0
    memo = [0 for i in range(d)]
    for j in range(d):
        if (i>>j)&1:
            ttl += li[j][1]+(j+1)*li[j][0]*100
            cnt += li[j][0]
            memo[j] = 1

    if ttl < g:
        memo2 = g- ttl
        for j in range(d-1,-1,-1):
            if memo[j] == 0:
                if memo2%(100*(j+1)) == 0:
                    cnt2 = min(memo2//(100*(j+1)),p[j]-1)
                    cnt += cnt2
                    ttl += cnt2*(100*(j+1))
                else:
                    cnt += memo2//(100*(j+1))+1
                    ttl += (memo2//(100*(j+1))+1)*(100*(j+1))
                break
    if ttl >= g:
        ans = min(ans,cnt)
    

    
    

print(ans)

Submission status: Runtime Error

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

for i in range(d):
    p,c = map(int,input().split())
    li.append([p,c])

ans = 10**9
for i in range(1<<d):
    ttl = 0
    cnt = 0
    memo = [0 for i in range(d)]
    for j in range(d):
        if (i>>j)&1:
            ttl += li[j][1]+(j+1)*li[j][0]*100
            cnt += li[j][0]
            memo[j] = 1
    #print(memo,ttl)
    if ttl < g:
        memo2 = g- ttl
        for j in range(d-1,-1,-1):
            if memo[j] == 0:
                if memo2%(100*(j+1)) == 0:
                    cnt2 = min(memo2//(100*(j+1)),li[j][0]-1)
                    cnt += cnt2
                    ttl += cnt2*(100*(j+1))
                    #print(44444444)
                else:
                    cnt2 = min(memo2//(100*(j+1)+1),li[j][0]-1)
                    cnt += cnt2
                    ttl += cnt2*(100*(j+1))
                break
    if ttl >= g:
        ans = min(ans,cnt)
    
    if ans == cnt:
        #print(memo,ttl,111111)
    
    

print(ans)

Submission status: Runtime Error

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

ans = float("inf")
for b in range(1<<d):
    m = set(range(1, d+1))
    c = 0
    s = 0
    for i in range(d):
        if b & (1<<i):
            c += pc[i][0]
            s += 100*(i+1)*pc[i][0] + pc[i][1]
            m.discard(i+1)
    if s >= g:
        ans = min(ans, c)
        continue
    while s < g:
        p = pc[max(m)-1][0]
        for _ in range(p):
            c += 1
            s += 100*max(m)
            if s >= g:
                break
        m.discard(max(m))
    ans = min(ans, c)
print(ans)

Submission status: Runtime Error

Solution code:
def dfs(i, total, S, remain):
    global ans
    if i == D:
        if S < G:
           use = max(remain)
           N = min(L[use-1][0], (G-S)//(100*use)
           S += 100 * N * use
           total += N
           
        if S >= G:
           ans = min(ans, total)
    else:
        dfs(i+1, total, S, remain)
        dfs(i+1, total + L[i][0], S + 100 * (i+1) * L[i][0] + L[i][1], remain - {i+1})

D, G = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(D)]
ans = 10 ** 9

dfs(0, 0, 0, set(range(1, D+1)))

print(ans)

Submission status: Runtime Error

Solution code:
def dfs(i, total, S, remain):
    global ans
    if i == D:
        if S < G:
           """
           If all the problems of the segment don't have to be calculated,
           it is preferable to solve some of the segment with the highest rate.
           """
           use = max(remain)
           N = min(L[use-1][0], (G-S)//(100*L[use-1][0]))
           S += 100 * N * use
           total += N
           
        if S >= G:
           ans = min(ans, total)
    else:
        dfs(i+1, total, S, remain)
        dfs(i+1, total + L[i+1][0], S + 100 * (i+1) * L[i+1][0] + L[i+1][1], remain - (i+1))

D, G = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(D)]
ans = 10 ** 9

dfs(0, 0, 0, set(range(1, D+1)))

print(ans)

Submission status: Runtime Error

Solution code:
def dfs(i, total, S, remain):
    global ans
    if i == D:
        if S < G:
           """
           If all the problems of the segment don't have to be calculated,
           it is preferable to solve some of the segment with the highest rate.
           """
           use = max(remain)
           N = min(L[use-1][0], (G-S)//(100*L[use-1][0])
           S += 100 * N * use
           total += N
           
        if S >= G:
        ans = min(ans, total)
    else:
        dfs(i+1, total, S, remain)
        dfs(i+1, total + L[i+1][0], S + 100 * (i+1) * L[i+1][0] + L[i+1][1], remain - (i+1))

D, G = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(D)]
ans = 10 ** 9

dfs(0, 0, 0, set(range(1, D+1)))

print(ans)

Submission status: Runtime Error

Solution code:
x = [list(map(int, input().split())) for i in range(d)]
ans2=float('inf')

for i in range(2**d):
    v=[0]*d
    ans=0
    ans1=0
    for j in range(d):
        if (i>>j)&1==1:
            ans+=(x[j][0]*100*(j+1))+x[j][1]
            ans1+=x[j][0]
            v[j]=1


    if ans<g:
        for k in range(d):
            if v[d-k-1]==0:
                if g-ans<=(x[d-k-1][0]-1)*100*(d-k):
                    w=-(-(g-ans)//(100*(d-k)))

                    ans2=min(ans2,ans1+w)
                else:
                    break
    else:
        ans2=min(ans2,ans1)
print(ans2)

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<vector>
#include<cmath>
#include<queue>
#include<utility>
#include<algorithm>

using namespace std;

int main(){
  int d,g;cin >> d >> g;
  g=int(g/100);
  vector< pair<int,int> > pc(d);
  int P=0;int C=0;
  for(int i=0;i<d;i++){
    int p,c;cin >> p >> c;c=int(c/100);
    pc[i]=make_pair(p,c);
    C+=(c+p*(i+1));P+=p;
  }
  vector<int> dp(C+1,0);
  for(int i=0;i<d;i++){
    vector<int> dp_sub(C+1,0);
    for(int j=0;j<C+1;j++){
      if(j==0){
        for(int k=1;k<pc[i].first+1;k++){
          if(k!=pc[i].first){dp_sub[k*(i+1)]=k;}
          else{dp_sub[k*(i+1)+pc[i].second]=k;}
        }
      }else if(dp[j]!=0){
        for(int k=1;k<pc[i].first+1;k++){
          if(k!=pc[i].first){
            if(dp_sub[j+k*(i+1)]!=0){
              dp_sub[j+k*(i+1)]=min(dp[j]+k,dp_sub[j+k*(i+1)]);
            }else{
              dp_sub[j+k*(i+1)]=dp[j]+k;
            }
          }else{
            if(dp_sub[j+k*(i+1)+pc[i].second]!=0){
              dp_sub[j+k*(i+1)+pc[i].second]=min(dp[j]+k,dp_sub[j+k*(i+1)+pc[i].second]);
            }else{
              dp_sub[j+k*(i+1)+pc[i].second]=dp[j]+k;
            }
          }
        }
      }
    }
    for(int j=0;j<C+1;j++){
      if(dp_sub[j]!=0){
        if(dp[j]==0){
          dp[j]=dp_sub[j];
        }else{
          dp[j]=min(dp[j],dp_sub[j]);
        }
      }
    }
  }
  int m=P;
  for(int i=g;i<C+1;i++){
    if(dp[i]!=0){m=min(m,dp[i]);}
  }
  cout << m << endl;
}