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: Accepted

Solution code:
N, G = map(int, input().split())
bonus = []
problems = []
for _ in range(N):
    PI, CI = map(int, input().split())
    problems.append(PI)
    bonus.append(CI)


def calc_rest_score():
    total = 0
    for i, pi in enumerate(problems):
        if pi:
            score = (i+1) * 100
            total += score * pi + bonus[i]
    return total


def make_plan(total_problem, total_score, flag):
    """
    :param total_score: ここまでの合計スコア
    :param total_problem: ここまでの合計問題数
    :param flag: 最後のスコア調整実施済みフラグ
    :return: 合計問題数
    """
    if total_score >= G:
        return total_problem

    # print("call ", total_problem, total_score, problems)

    rest_score = calc_rest_score()  # 残り全部解いたら何点になるのか
    if total_score + rest_score < G:
        # もう無理
        return 10000

    for i in range(N - 1, -1, -1):
        pi = problems[i]
        si = (i + 1) * 100
        if pi == 0:
            continue
        else:
            # 1. 全部解く
            problems[i] = 0
            pn1 = make_plan(total_problem + pi,
                            total_score + si * pi + bonus[i],
                            flag)
            problems[i] = pi
            # print("pn1:", pn1)

            # 2. 部分的に解く(ただし最後の調整として)
            if not flag:
                # 1問ずつ減らして結果を比較
                min_pn = 10000  # 多分問題数はmaxでも5500問くらい
                for j in range(pi, -1, -1):  # 1～(pi-1)
                    plus_score = si * j
                    if j == pi:
                        plus_score += bonus[i]
                    problems[i] = 0
                    pn = make_plan(total_problem+j,
                                   total_score+plus_score,
                                   True if j != 0 else flag)
                    # print("test", j, pn)
                    problems[i] = pi
                    if pn < min_pn:
                        min_pn = pn
                pn2 = min_pn
            else:
                pn2 = 10000

            return min(pn1, pn2)
    else:
        # 問題を避けすぎて解けない
        return 10000


print(make_plan(0, 0, False))

Submission status: Accepted

Solution code:
from pprint import pprint
def main():
    D,G = map(int, input().split())
    p,c = [0]*D,[0]*D
    for i in range(D):
        p[i],c[i] = map(int, input().split())
    qnum = sum(p)
    # dp[i][j] := i問目まででj個解いたときの最大得点
    dp = [[0]*(qnum+1) for _ in range(D+1)]
    dp[0] = [0]*(qnum+1)
    ans = qnum
    for i in range(1,D+1):
        # i問目までを見る
        for j in range(qnum+1):
            # 全部でj回解く
            for k in range(min(p[i-1]+1, j+1)):
                # i問目をk個解く
                if k<p[i-1]:
                    dp[i][j] = max(dp[i][j], dp[i-1][j-k]+100*i*k)
                else:
                    dp[i][j] = max(dp[i][j], dp[i-1][j-k]+100*i*k+c[i-1])
                if dp[i][j]>=G:
                    ans = min(ans, j)
    pprint(ans)

main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

d, g = LI()
pc = [LI() for _ in range(d)]

ans = inf
for i in range(1<<d):
    rest = 1
    rest_count = 0
    score = 0
    count = 0
    for j in range(d):
        p, c = pc[j]
        if (i >> j) & 1:
            score += p * (j + 1) * 100 + c
            count += p
        else:
            if rest < (j + 1) * 100:
                rest = (j + 1) * 100
                rest_count = p
    if score >= g:
        ans = min(ans, count)
    else:
        if math.ceil((g - score) / rest) <= rest_count:
            count += math.ceil((g - score) / rest)
            ans = min(ans, count)
print(ans)

Submission status: Accepted

Solution code:
from itertools import product
D, G = map(int, input().split())
P, C = zip(*[map(int, input().split()) for _ in range(D)])
INF = 10**18
ans = INF
for bit in product((0, 1), repeat=D):
    p = list(P)
    cnt = 0
    score = 0
    for i in range(D):
        if bit[i]:
            score += C[i]
            score += P[i]*100*(i+1)
            cnt += P[i]
            p[i] = 0

    if score+sum(p[i]*100*(i+1) for i in range(D)) < G:
        continue

    idx = D-1
    while score < G:
        while not p[idx]:
            idx -= 1
        score += 100*(idx+1)
        p[idx] -= 1
        cnt += 1
    if cnt < ans:
        ans = cnt
print(ans)

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
D,G = IL()
L = ILL(D)
L = [((i+1)*100,L[i][0],L[i][1]) for i in range(D)]
import copy
def toku(L_,b):
  score = G
  count = 0
  Lset = copy.deepcopy(L_)
  for i in range(D):
    if (b>>i)&1:
      s,a,t = L_[i]
      score -= s*a+t
      Lset.remove(L_[i])
      count += a
  while score>0:
    if Lset:
      s,a,t = Lset.pop()
      if s*(a-1)>score:
        count += -(-score//s)
        score = 0
      else:
        score -= s*(a-1)
        count += a-1
    else:
      count = INF
      score = 0      
  return count

MIN = INF
for b in range(1<<D):
  MIN = min(MIN,toku(L,b))
  
print(MIN)

Submission status: Accepted

Solution code:
import sys
import math

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

d,g = nm()
comp = [nl() for _ in range(d)]
ans = 10**10
check = set([i for i in range(d)])
for i in range(2**d):
    res = 0
    times = 0
    visited = set()
    for j in range(d):
        if (i >> j) & 1:
            res += 100 * (j+1)*comp[j][0] + comp[j][1]
            times += comp[j][0]
            visited.add(j)
    if res < g:
        ma = max(check-visited)
        waru =  100 * (ma+1)
        waru_times = math.ceil((g-res)/waru)
        res += 100*waru_times*waru
        if waru_times > comp[ma][0]-1 or res < g:
            continue
        times += waru_times
        if ans > times:
            ans = times
    elif res >= g:
        if ans > times:
            ans = times
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

def main():
    D, G = map(int, input().split())
    p = [None] * D
    c = [None] * D
    for i in range(D):
        p[i], c[i] = map(int, input().split())
    
    ans = 10**18
    for i in range(2**D):
        tmp = 0
        score = 0
        k = 0
        for j in range(D):
            if (i >> j) & 1:
                score += p[j]*100*(j+1) + c[j]
                tmp += p[j]
            else:
                k = j
        tmp2 = 0
        while score < G and tmp2 < p[k]:
            score += 100 * (k+1)
            tmp2 += 1
        if score >= G:
            ans = min(ans,tmp+tmp2)
            # print(i,tmp,score)
    print(ans)



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from itertools import product

d, g = map(int, input().split())
prob = []
for i in range(1, d + 1):
    p, c = map(int, input().split())
    prob.append((i * 100, p, c))  # score, num, bonus

ans = 1000000000
# repeatは
for prd in product([0, 1], repeat=d):
    cnt = 0
    allScore = 0
    for j, (score, num, bonus) in zip(prd, prob):
        if j == 1:
            cnt += num
            allScore += score * num + bonus

    if allScore < g:
        for j, (score, num, bonus) in zip(prd, prob):
            if j == 0 and (score * num >= g - allScore):
                rest = (g - allScore) // score
                cnt += rest
                allScore += score * rest
                break

    if allScore >= g:
        ans = min(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]
ans = 1001
for i in range(1<<d): # 0から2^D -1までの全難易度についてそれを解くか解かないかの組み合わせ
    count, score, left = 0, 0, 0
    for j in range(d): # 100からD*100の難易度まで
        if (i >> j) & 1: # j*100の難易度の問題を解く場合(最後の桁が1かで判定)
            score += (j+1)*100*pc[j][0] + pc[j][1] # 全部の問題をといてボーナスポイントも得る
            count += pc[j][0] # 全部の問題解いた分をカウント
        else: left = j # 解かない場合は全て残りに回される
    for j in range(pc[left][0]): # 残っている時
        if score >= g: break
          
        score += (left+1)*100 # gを超えない範囲で1つずつ足され、カウントされる
        count += 1
    if score >= g: ans = min(ans, count) # gを越えるカウントの中でもっとも小さいものが答え
print(ans)

Submission status: Accepted

Solution code:
(d, g), *s = [list(map(int, i.split())) for i in open(0)]
s = [[i[0] * -~n * 100 + i[1], i[0]] for n, i in enumerate(s)]
a = 10**3
for b in range(1 << d):
    su = sum(s[i][0] * (b >> i & 1) for i in range(d))
    n = sum(s[i][1] * (b >> i & 1) for i in range(d))
    if su < g:
        m = d-bin(b)[2:].zfill(d).find("0")
        e = (su-g)//(m*100)
        if -e < s[m-1][1]:
            a = min(a,n - e)
    if su >= g:
        a = min(a,n)
print(a)

Submission status: Accepted

Solution code:
(d, g), *s = [list(map(int, i.split())) for i in open(0)]
def c(i,t,l):
    if i==d:
        if t>=g:
            return sum(l)
        else:
            m=d-l[::-1].index(0)
            e = (t - g) // (m * 100)
            if -e < s[m-1][0]:
                return sum(l)-e
            else:
                return 10**3
    return min(c(i+1,t,l+[0]),c(i+1,t+s[i][0]*-~i*100+s[i][1],l+[s[i][0]]))
print(c(0,0,[]))

Submission status: Accepted

Solution code:
d,g = map(int,input().split())
P = [0]*d
C = [0]*d
for i in range(d):
    P[i],C[i] = map(int,input().split())

ans = float('inf')
bit_n = d
for i in range(2**d):
    tmp = 0
    solved = 0
    for j in range(d):
        if ((i>>j)&1):
            tmp+=C[j]
            tmp+=(j+1)*100*P[j]
            solved+=P[j]
    if tmp>=g:
        ans = min(ans,solved)
    else:
        for j in range(d-1,-1,-1):
            if tmp>=g:
                ans = min(ans,solved)
                break
            if not ((i>>j)&1):
                for k in range(P[j]):                 
                    if tmp>=g:
                        ans = min(ans,solved)
                        break
                    solved+=1
                    tmp+=(j+1)*100
print(ans)

Submission status: Accepted

Solution code:
import math

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

ret = 1000 ** 10
for i in range(2 ** D):
    total = 0
    cnt = 0
    for p in range(D):
        if (i >> p) & 1:
            cnt += lst[p][0]
            total += lst[p][0] * (p + 1) * 100 + lst[p][1]

    for p in range(D)[::-1]:
        delta = G - total
        if delta <= 0:
            break
        if not ((i >> p) & 1):
            n = min(math.ceil(delta / ((p + 1) * 100)), lst[p][0])
            cnt += n
            total += n * (p + 1) * 100
    ret = min(ret, cnt)
print(ret)

Submission status: Accepted

Solution code:
import math

d, g = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(d)]
ans = float('inf')

for i in range(2 ** d):
    sum = 0
    count = 0
    s = set(_ for _ in range(1, d + 1))
    for j in range(d):
        if (i >> j) & 1 == 1:
            sum += l[j][0] * (j + 1) * 100 + l[j][1]
            count += l[j][0]
            s.discard(j + 1)
    if sum < g:
        t = max(s)
        n = min(l[t - 1][0], math.ceil((g - sum) / (t * 100)))
        count += n
        sum += n * t * 100
    if sum >= g:
        ans = min(ans, count)
print(ans)

Submission status: Accepted

Solution code:
import math

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

ret = 1000 ** 10
for i in range(2 ** D):
    total = 0
    cnt = 0
    digit = 1
    for p in range(D):
        if (digit << p) & i:
            cnt += lst[p][0]
            total += lst[p][0] * (p + 1) * 100 + lst[p][1]

    for p in range(D)[::-1]:
        if not ((digit << p) & i):
            delta = max(0, G - total)
            n = min(math.ceil(delta / ((p + 1) * 100)), lst[p][0])
            cnt += n
            total += n * (p + 1) * 100
    ret = min(ret, cnt)
print(ret)

Submission status: Accepted

Solution code:
D,G=map(int,input().split())
PC=[list(map(int,input().split())) for i in range(D)]
ans=10**18
import math
for i in range(2**D):
  _i=i
  j=0
  s=[]
  _ans=0
  g=0
  while i>0:
    if i%2==1:
      _ans+=PC[j][0]
      g+=(PC[j][0]*100*(j+1)+PC[j][1])
      s.append(j)
    j+=1
    i=i//2
  if g>=G:
    ans=min(ans,_ans)
  else:
    j=D-1
    while j in s:
      j-=1
    if j>-1 and G-g<=(PC[j][0]-1)*100*(j+1):
      _ans+=math.ceil((G-g)/100/(j+1))
      ans=min(ans,_ans)
print(ans)

Submission status: Accepted

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

def dfs(d, rest): # difficulty, rest score
    if d <= 0: return 10**9
    num, bonus = data[d-1] # num of problems, bonus
    # now, use or don't use difficulty d?
    use = min(rest//(d*100), num) # num when use
    score = use * d * 100 # score when use
    if use == num: score += bonus # ?perfect
    if rest - score > 0: # ?rest
        use += dfs(d-1, rest - score) # rest of score -> recursion
    not_use = dfs(d-1, rest) # num when don't use -> recursion
    return min(use, not_use)

print(dfs(d, g))

Submission status: Accepted

Solution code:
def main():
    from itertools import product

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

    prob = []
    for j in range(1, D + 1):
        p, c = map(int, input().split())
        prob.append((j * 100, p, c))  # score,amount,bonus

    ans = -1
    for prd in product([0, 1], repeat=D):
        cnt = 0
        g = 0
        for j, (score, amount, bonus) in zip(prd, prob):
            if j:
                cnt += amount
                g += score * amount + bonus

        if g < G:
            for j, (score, amount, bonus) in reversed(tuple(zip(prd, prob))):
                if (not j) and (score * amount >= G - g):
                    use = (G - g + score - 1) // score
                    cnt += use
                    g += score * use
                    break

        if (g < G) or (~ans and ans <= cnt): continue
        ans = cnt

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import deque
d,g=map(int,input().split())
pc=[list(map(int,input().split())) for _ in range(d)]
ans=10**7
for i in range(2**d):
  cnt=0
  c=0
  l=deque([])
  for j in range(d):
    if (i>>j)&1:
      cnt+=(j+1)*100*pc[j][0]+pc[j][1]
      c+=pc[j][0]
      l.appendleft([1,j])
    else:
      l.appendleft([0,j])
  if cnt<g:
    for n,m in l:
      if n==0:
        if g-(cnt+pc[m][0]*(m+1)*100)<=0:
          if (g-cnt)%((m+1)*100)==0:     
            c+=(g-cnt)//((m+1)*100)
            cnt=g
          else:
            c+=(g-cnt)//((m+1)*100)+1
            cnt=g
        break
  if cnt>=g:
    ans=min(ans,c)
print(ans)

Submission status: Accepted

Solution code:
d,g = map(int,input().split())
P,C = [0]*d,[0]*d
for i in range(d): P[i],C[i] = map(int,input().split())
ans = 10**9
for bin in range(1<<d):
    cnt = tot = rest_max_bit = 0
    for i in range(d):
        if bin & 1<<i:
            t = (i + 1)*100
            tot += P[i]*t + C[i]
            cnt += P[i]
        else: rest_max_bit = i
    if tot < g:
        t = (rest_max_bit + 1)*100
        p = (g - tot + t - 1)//t
        if p >= P[rest_max_bit]: continue
        cnt += p
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:
d,g = map(int,input().split())
P,C = [0]*d,[0]*d
for i in range(d): P[i],C[i] = map(int,input().split())
ans = 10**9
for bin in range(0, 1<<d):
    cnt = tot = 0
    rest_max_bit = -1
    for i in range(d):
        if bin & 1<<i:
            t = (i+1)*100
            tot += P[i]*t + C[i]
            cnt += P[i]
        else: rest_max_bit = i
    if tot < g:
        t = (rest_max_bit + 1)*100
        p = (g - tot + t - 1)//t
        if p >= P[rest_max_bit]: continue
        cnt += p
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:
d,g = map(int,input().split())
P,C = [0]*d,[0]*d
for i in range(d): P[i],C[i] = map(int,input().split())
ans = 10**9
for bin in range(0, 1<<d):
    cnt = tot = 0
    rest_max_bit = -1
    for i in range(d):
        if bin & 1<<i:
            t = (i+1)*100
            tot += P[i]*t + C[i]
            cnt += P[i]
        else: rest_max_bit = i
    if tot >= g:
        ans = min(ans, cnt)
        continue
    if rest_max_bit < 0: continue
    t = (rest_max_bit+1)*100
    p = (g+t-tot-1)//t
    if p < P[rest_max_bit]: ans = min(ans, cnt + p)
print(ans)

Submission status: Accepted

Solution code:
d,g = map(int,input().split())
P,C = [0]*d,[0]*d
for i in range(d): P[i],C[i] = map(int,input().split())
ans = 10**9
for bin in range(0, 1<<d):
    cnt = tot = 0
    rest_max_bit = -1
    for i in range(d):
        if bin & 1<<i:
            t = (i+1)*100
            tot += P[i]*t + C[i]
            cnt += P[i]
        else: rest_max_bit = i
    if tot >= g:
        ans = min(ans, cnt)
        continue
    if rest_max_bit < 0: continue
    t = (rest_max_bit+1)*100
    rest_g = g - tot
    p = min(P[rest_max_bit]-1, (rest_g+t-1)//t) # [0,pi-1]
    if p*t >= rest_g: ans = min(ans, cnt + p)
print(ans)

Submission status: Accepted

Solution code:
d,g = map(int,input().split())
P,C = [0]*d,[0]*d
for i in range(d): P[i],C[i] = map(int,input().split())
ans = 10**9
for bin in range(1, 1<<d):
    cnt = tot = 0
    for i in range(d):
        if bin & 1<<i:
            cnt += P[i]
            tot += P[i]*(i+1)*100 + C[i]
    if tot < g: continue
    ans = min(ans, cnt)
    for i in range(d):
        if bin & 1<<i:
            t = (i+1)*100
            rest_g = g - (tot - P[i]*t - C[i])
            p = max(0, (rest_g+t-1)//t) # round up
            ans = min(ans, cnt - (P[i] - p))
print(ans)

Submission status: Accepted

Solution code:
d,g = map(int,input().split())
g //= 100
P,C = [0]*d,[0]*d
for i in range(d):
    P[i],C[i] = map(int,input().split())
    C[i] //= 100
ans = 10**9
for bin in range(1, 1<<d):
    cnt = tot = 0
    for i in range(d):
        if bin & 1<<i:
            cnt += P[i]
            tot += P[i]*(i+1) + C[i]
    if tot < g: continue
    ans = min(ans, cnt)
    for i in range(d):
        if bin & 1<<i:
            rest_g = g - (tot - P[i]*(i+1) - C[i])
            p = max(0, (rest_g+i)//(i+1)) # round up
            ans = min(ans, cnt - (P[i] - p))
print(ans)

Submission status: Accepted

Solution code:
d,g = map(int,input().split())
P,C = [0]*d,[0]*d
for i in range(d): P[i],C[i] = map(int,input().split())
ans = 10**9
for bin in range(1, 1<<d):
    cnt = tot = 0
    for i in range(d):
        if bin & 1<<i:
            cnt += P[i]
            tot += P[i]*(i+1)*100 + C[i]
    if tot < g: continue
    ans = min(ans, cnt)
    for i in range(d):
        if bin & 1<<i:
            now_cnt = cnt
            now_tot = tot - C[i]
            for k in range(P[i]-1):
                now_cnt -= 1
                now_tot -= (i+1)*100
                if now_tot >= g: ans = min(ans, now_cnt)
print(ans)

Submission status: Accepted

Solution code:
d,g = map(int,input().split())
g //= 100
P,C = [],[]
for i in range(1, d+1):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c//100)
ans = 10**9
for bin in range(1, 1<<d):
    cnt = tot = 0
    for i in range(d):
        if bin & 1<<i:
            cnt += P[i]
            tot += P[i]*(i+1) + C[i]
    if tot < g: continue
    ans = min(ans, cnt)
    for i in range(d):
        if bin & 1<<i:
            rest_g = g - (tot - P[i]*(i+1) - C[i])
            p = max(0, (rest_g+i)//(i+1)) # round up
            ans = min(ans, cnt - (P[i] - p))
print(ans)

Submission status: Accepted

Solution code:
d,g = map(int,input().split())
g //= 100
P,C = [],[]
for i in range(1, d+1):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c//100)
ans = 10**9
for bin in range(1, 1<<d):
    cnt = tot = 0
    for j in range(d):
        if bin & 1<<j:
            cnt += P[j]
            tot += P[j]*(j+1) + C[j]
    if tot < g: continue
    ans = min(ans, cnt)
    for j in range(d):
        if bin & 1<<j:
            rest_g = g - (tot - P[j]*(j+1) - C[j])
            p = max(0, (rest_g+j)//(j+1)) # round up
            ans = min(ans, (cnt - P[j]) + min(p, P[j]))
print(ans)

Submission status: Accepted

Solution code:
d,g = map(int,input().split())
g //= 100
P,C = [],[]
for i in range(1, d+1):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c//100)
ans = 10**9
# print(P)
# print(C)
for bin in range(1, 1<<d):
    cnt = tot = 0
    for j in range(d):
        if bin & 1<<j:
            cnt += P[j]
            tot += P[j]*(j+1) + C[j]
    if tot < g: continue
    ans = min(ans, cnt)
    # print('tot',tot, end=' ')
    # print('cnt',cnt, end='\n')
    for j in range(d):
        if bin & 1<<j:
            init_cnt = cnt - P[j]
            init_tot = tot - (P[j]*(j+1) + C[j])
            rest_g = g - init_tot
            k = max(0, (rest_g+j)//(j+1)) # round up, required quantity
            # print('Pj',P[j], end=' ')
            # print('Cj',C[j], end=' ')
            # print('init_cnt',init_cnt, end=' ')
            # print('init_tot',init_tot, end=' ')
            # print('rest_g',rest_g, end=' ')
            # print('k',k, end='\n')
            if k < P[j]:
                # ans = init_cnt + k
                ans = min(ans, init_cnt + k)
                # print('init_cnt+k',init_cnt+k, end='\n')
print(ans)

Submission status: Accepted

Solution code:
d,g = map(int,input().split())
P,C = [],[]
for i in range(1, d+1):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)
ans = 10**9
for bin in range(1, 1<<d):
    cnt = tot = 0
    for j in range(d):
        if bin & 1<<j:
            cnt += P[j]
            tot += P[j]*(j+1)*100 + C[j]
    if tot < g: continue
    ans = min(ans, cnt)
    for j in range(d):
        if bin & 1<<j:
            now_cnt = cnt
            now_tot = tot - C[j]
            for k in range(P[j]-1):
                now_cnt -= 1
                now_tot -= (j+1)*100
                if now_tot >= g: ans = min(ans, now_cnt)
print(ans)

Submission status: Accepted

Solution code:
d,g = map(int,input().split())
P,C = [],[]
for i in range(1, d+1):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)
ans = 10**9
for bin in range(1, 1<<d):
    cnt = tot = 0
    for j in range(d):
        if bin & 1<<j:
            cnt += P[j]
            tot += P[j]*(j+1)*100 + C[j]
    if tot >= g: ans = min(ans, cnt)
    for j in range(d):
        if bin & 1<<j:
            now_cnt = cnt
            now_tot = tot - C[j]
            for k in range(P[j]-1):
                now_cnt -= 1
                now_tot -= (j+1)*100
                if now_tot >= g: ans = min(ans, now_cnt)
print(ans)

Submission status: Accepted

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 = 1e9
for i in range(2 ** d):
    sum_ = 0
    num = 0
    rest_max = -1
    for j in range(d):
        if ((i >> j) & 1):
            sum_ += 100 * (j + 1) * p[j] + c[j]
            num += p[j]
        else:
            rest_max = j
    if (sum_ < g):
        s1 = 100 * (rest_max + 1)
        need = (g - sum_ + s1 - 1) // s1
        if need >= p[rest_max]:
            continue
        num += need
    ans = min(ans, num)
print(ans)

Submission status: Accepted

Solution code:
import math

n, k = map(int, input().split())
pn = []
bp = []

for i in range(n):
    p, b = map(int, input().split())
    pn.append(p)
    bp.append(b)

res = 10**9

for i in range(1 << n):
    pnt = 0
    num = 0
    x = i ^ (2 ** n - 1)
    for j in range(n):
        if (i >> j) & 1 == 1:
            pnt += (j+1) * 100 * pn[j] + bp[j]
            num += pn[j]
    if pnt >= k:
        res = min(res, num)
    else:
        for l in range(n - 1, -1, -1):
            if (x >> l) & 1 == 1:
                d = min(pn[l], math.ceil((k - pnt)//100/(l + 1)))
                #print(num, pnt, d, d*100*(l+1), num+d, pnt+d*100*(l+1))
                pnt += (l+1) * 100 * d
                num += d
                break
        if pnt >= k:
            res = min(res, num)
print(res)

Submission status: Accepted

Solution code:
d, g =map(int,input().split())
a = []
b = []
for i in range(d):
    p,c = map(int,input().split())
    a.append(p)
    b.append(c)
ans = float('inf')
for i in range(2**d):
    ten = 0
    mon = 0
    for j in range(d):
        if i>>j&1:
            ten += a[j]*((j+1)*100)+b[j]
            mon += a[j]
    if ten < g:
        for j in range(d):
            tenp = ten
            monp = mon
            if i>>j&1 == 0:
                for k in range(a[j]-1):
                    tenp += (j+1)*100
                    monp += 1
                    if tenp >= g:
                        ans = min(ans,monp)
    else:

        ans = min(ans,mon)
print(ans)