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:
d,g = map(int, input().split())
p,c = [],[]
for i in range(d):
    a,b = list(map(int, input().split()))
    p.append(a)
    c.append(b)
res = 10**5
for i in range(2**d):
    bi = bin(i)[2:].zfill(d)
    score = 0
    count = 0
    isContinue = False
    for j in range(d):
        if bi[j]=='1':
            if g-score >= 100*(j+1)*p[j]:
                score += 100*(j+1)*p[j]+c[j]
                count += p[j]
            else:
                isContinue = True
                break
    if isContinue:
        continue
    if score < g:
        for j in range(d-1, -1, -1):
            if bi[j]=='0':
                if g-score >= 100*(j+1)*p[j]:
                    isContinue = True
                    break
                if (g-score) % (100*(j+1))==0:
                    count += (g-score)//(100*(j+1))
                else:
                    count += (g-socre)//(100*(j+1))
                    count += 1
                    break
    if isContinue:
        continue
    res = min(res,count)

print(res)

Submission status: Runtime Error

Solution code:
d,g = map(int, input().split())
p,c = [],[]
for i in range(d):
    a,b = list(map(int, input().split()))
    p.append(a)
    c.append(b)
res = 10**5
for i in range(2**d):
    bi = bin(i)[2:].zfill(d)
    score = 0
    count = 0
    isContinue = False
    for j in range(d):
        if bi[j]=='1':
            if g-score >= 100*(j+1)*p[j]:
                score += 100*(j+1)*p[j]+c[j]
                count += p[j]
            else:
                isContinue = True
                break
    if isContinue:
        continue
    if score < g:
        for j in range(d-1, -1, -1):
            if bi[j]=='0':
                if g-score >= 100*(j+1)*p[j]:
                    isContinue = True
                    break
                if (g-score) % (100*(j+1))==0:
                    count += (g-score)//(100*(j+1))
                else:
                    count += (g-socre)//(100*(j+1))
                    count += !
                    break
    if isContinue:
        continue
    res = min(res,count)

print(res)

Submission status: Runtime Error

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

D, G = na()
p = []
c = []
for i in range(D):
    x, y = na()
    p.append(x)
    c.append(y)

# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

D, G = s_inpl()
p, c = [], []

for i in range(D):
    pi, ci = s_inpl()
    p.append(pi)
    c.append(ci)

ans = INF
for i in range(1<<D):
    ct = 0
    score = 0
    for j in range(D):
        if i>>j&1:
            score += c[j]
            score += p[j] * (j+1) * 100
            ct += p[j]
    for j in range(D-1, -1, -1):
        if i>>j&1: continue
        if score >= G: break
        g = (j+1)*100
        got = (G-score+g-1)//g
        score += min(got, p[j]) * g
        ct += min(got, p[j])
    ans = min(ans, ct)
print(ans)

Submission status: Runtime Error

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

for i,row in enumerate(pc):
    s = (i+1)*row[1] * 100 + row[2]
    ave = s/row[1]
    pc[i].append(s)
    pc[i].append(ave)

out = 0
while 1:
    check=False
    i_list = []
    for i,row in enumerate(pc):
        if G<row[3]:
            check=True
            i_list.append(i)
    if check == False:
        #どれをコンプリートしても目標を超えない
        #問題数当たり平均が最高の問題セットを解く
        tmp = [row[4] for row in pc]
        i = tmp.index(max(tmp))
        out += pc[i][1]
        G -= pc[i][3]
        pc.pop(i)
    else:
        #どれかをコンプリートすると目標を達成
        #最小問題数のセット または 最高得点問題での必要数
        tmp = [pc[i][1] for i in i_list]
        m = min(tmp)
        if pc[-1][3] > G:
            m = min(m,(G-1)//((pc[-1][0]+1)*100)+1)
        out += m
        break
print(out)

Submission status: Runtime Error

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

for i,row in enumerate(pc):
    s = (i+1)*row[1] * 100 + row[2]
    ave = s/row[1]
    pc[i].append(s)
    pc[i].append(ave)

out = 0
while 1:
    check=False
    i_list = []
    for i,row in enumerate(pc):
        if G<row[3]:
            check=True
            i_list.append(i)
    if check == False:
        #どれをコンプリートしても目標を超えない
        #問題数当たり平均が最高の問題セットを解く
        tmp = [row[4] for row in pc]
        i = tmp.index(max(tmp))
        out += pc[i][1]
        G -= pc[i][3]
        pc.pop(i)
    else:
        #どれかをコンプリートすると目標を達成
        #最小問題数のセット または 最高得点問題での必要数
        tmp = [pc[i][1] for i in i_list]
        m = min(tmp)
        if pc[-1][3] > G:
            m = min(m,G//((pc[-1][0]+1)*100))
        out += m
        break
print(out)

Submission status: Runtime Error

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

def solve(g,i):
    if i<=0:
        return float('inf')
    n = min(int(G/100*i),PC[i-1][0])
    score = 100 * i * n 
    if n == PC[i-1][0]:
        score += PC[i-1][1]
    if g > score:
        n += solve(g-score,i-1)
    return min(n,solve(g,i-1))

print(solve(g,d))

Submission status: Runtime Error

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

def solve(G,i):
    if i<=0:
        return float('inf')
    n = min(int(G/100*i),PC[i-1][0])
    score = 100 * i * n 
    if n == PC[i-1][0]:
        score += PC[i-1][1]
    if G > score:
        n += solve(G-score,i-1)
    return min(n,solve(G,i-1))

print(solve(G,D))

Submission status: Runtime Error

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

for _ in range(D):
    p, c = map(int, input().split())
    P.append(p); C.append(c)

ans = float('inf')

for bit in range(2**D):
    score, solve_num = 0, 0
    for i in range(D):
        if (bit >> i) & 1:
            score += (100 * (i+1) * P[i] + C[i])
            solve_num += P[i]
            is_solve[i] += P[i]

    for i in range(D-1, -1, -1):
        if score >= G:
            break

        if (bit >> i) & 1:
            continue

        for j in range(P[i]):
            score += 100*(i+1)
            solve_num += 1

            if score >= G:
                break

    ans = min(ans, solve_num)

print(ans)

Submission status: Runtime Error

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

for _ in range(D):
    p, c = map(int, input().split())
    P.append(p); C.append(c)

ans = float('inf')

for bit in range(2**D):
    score, solve_num = 0, 0
    for i in range(D):
        if (bit >> i) & 1:
            score += (100 * (i+1) * P[i] + C[i])
            solve_num += P[i]
            is_solve[i] += P[i]

    for i in range(D-1, -1, -1):
        if score >= G:
            break

        if (bit >> i) & 1:
            continue

        for j in range(p[i]):
            score += 100*(i+1)
            solve_num += 1

            if score >= G:
                break

    ans = min(ans, solve_num)

print(ans)

Submission status: Runtime Error

Solution code:
import itertools as it
D, G = map(int, input().split())
P, C = [], []
for _ in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)
A = it.permutations([i for i in range(D)])
ans = 10**9
for a in A:
    S, i, sub_ans = 0, 0, 0
    while 1:
        if S + (a[i] + 1) * 100 * P[a[i]] < G:
            S += (a[i] + 1) * 100 * P[a[i]]
            sub_ans += P[a[i]]
            S += C[a[i]]
        else:
            x = (G - S) // ((a[i] + 1) * 100)
            if S + (a[i] + 1) * x < G:
                x += 1
            sub_ans += x
            S += (a[i] + 1) * x
        S += C[a[i]]
        if S >= G:
            if sub_ans < ans:
                ans = sub_ans
            break
        i += 1
print(ans)

Submission status: Runtime Error

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

time_list = []
for i in range(1<<D):
    point = 0
    time = 0
    output = []
    for j in range(D): 
        #print(i,j+1,bin(i>>j))
        if ((i >> j) & 1) == 1: #ある数と1とのANDを取ることは，その数の右端のbitが0か1を調べることに等しい．iの右からj+1番目のbitが1かどうかを確認している．
            output.append(A[j])
    #print(output)
    for d in range(D):
        if ((i>>d) & 1) == 1:
            point += 100*(d+1)* p[d] + c[d]
            time += p[d]
    if point < G:
        # iで一番左側にある0を探す。
        for d in range(D)[::-1]:
            if ((i>>d) & 1) == 0: # and論理積は1==1以外はすべてfalse
                for k in range(p[d]):
                    if point < G:
                        point += 100*(d+1) 
                        time += 1
                    else: break
                break
            else: continue
    if point >= G:
        time_list.append(time)
print(min(time_list))

Submission status: Runtime Error

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


MAX_BIT = (1 << D)
# 各ビットが1のとき全部解く
def calc(patternBit):
    if patternBit >= MAX_BIT:
        return None
    p = patternBit
    score = 0
    ans1 = 0
    use_c = None
    for i, c in enumerate(Ci):
        s = (i + 1) * 100 #1問のスコア
        if p % 2 > 0:
            score += s * c[0] + c[1]
            ans1 += c[0]
        else:
            use_c = c + [s]
        p = p // 2
    if score < G:
        if use_c == None:
            return calc(patternBit + 1)
        remain = G - score
        add_count = remain // use_c[2]
        if remain % use_c[2] > 0:
            add_count += 1
        if add_count > use_c[0]:
            return calc(patternBit + 1)
        ans1 += add_count
    ans2 = calc(patternBit + 1)
    if ans2 != None:
        return min(ans1, ans2)
    return ans1
    
print(calc(0))

Submission status: Runtime Error

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


MAX_BIT = (1 << D)
# 各ビットが1のとき全部解く
def calc(patternBit):
    if patternBit >= MAX_BIT:
        return None
    p = patternBit
    score = 0
    ans1 = 0
    use_c = None
    for i, c in enumerate(Ci):
        s = (i + 1) * 100 #1問のスコア
        if p % 2 > 0:
            score += s * c[0] + c[1]
            ans1 += c[0]
        else:
            use_c = c + [s]
        p = p // 2
    if score < G:
        remain = G - score
        add_count = remain // use_c[2]
        if remain % use_c[2] > 0:
            add_count += 1
        if add_count > use_c[0]:
            return calc(patternBit + 1)
        ans1 += add_count
    ans2 = calc(patternBit + 1)
    if ans2 != None:
        return min(ans1, ans2)
    return ans1
    
print(calc(0))

Submission status: Runtime Error

Solution code:
# """
# コンプリートするものと、せざるものに分ける
# コンプリートしないものに関しては、得点の高い方から一個だけ潰す
# """

D, G = map(int, input().split())
ps_ini,cs = [], []
for i in range(D):
    p,c = map(int,input().split())
    ps_ini.append(p)
    cs.append(c)
q_min = 1000000
for i in range(2**D):
    Gtmp = G
    ps = [p for p in ps_ini]
    s = "{:05b}".format(i)[::-1]
    q_all = 0
    for j,(p,c) in enumerate(zip(ps,cs)):
        # ボーナスの考慮
        Gtmp -= (p*(j+1)*100+c)*int(s[j]) 
        q_all += p*int(s[j])
        ps[j] -= p*int(s[j])
    # print(s,ps)
    if Gtmp <= 0:
        q_min = min(q_min, q_all)
    else:
        # コンプしていない問題で一番大きいやつ
        ind = 0
        for i,p in enumerate(ps):
            if p != 0:
                ind = i
        # print(Gtmp,ind,Gtmp//((ind+1)*100))
        # 比較
        if Gtmp//((ind+1)*100) > ps[ind]:
            continue
        if Gtmp%((ind+1)*100) == 0:           #割り切れない
            q_all += (Gtmp//((ind+1)*100))
        else:                           #割り切れる
            q_all += (Gtmp//((ind+1)*100) + 1) #最大値をコンプする以外ありえん
        q_min = min(q_min, q_all)
print(q_min)

Submission status: Runtime Error

Solution code:
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr int mod = (int)1e9 + 7;
[[maybe_unused]] static constexpr int inf = 100100100;
[[maybe_unused]] static constexpr ll linf = 1e18;
[[maybe_unused]] static constexpr double eps = 1e-9;
[[maybe_unused]] static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a, b) for (ll i = a; i < b; ++i)
#define rrrep(i, a, b) for (ll i = a; i >= b; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second


ll D;
ll G;

int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    cin >> D >> G;

    vector<ll> p;
    vector<ll> c;
    rep(i, D) {
        ll p_, c_;
        cin >> p_ >> c_;
        p.pb(p_);
        c.pb(c_);
    }
    ll ans = linf;
    for (ll i = 0; i < (1 << D); ++i) {
        ll s = 0;
        ll n = 0;
        rep(j, D) {
            if (i & (1 << j)) {
                s += 100 * (j + 1) * p[j] + c[j];
                n += p[j];
            }
        }
        if (s >= G) {
            ans = min(ans, n);
            continue;
        }
        rep(j, D) {
            if (i & (1 << j)) continue;
            rep(k, p[j]) {
                    if (s + 100 * (j + 1) * k >= G) {
                    ans = min(ans, n + k);
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}

Submission status: Runtime Error

Solution code:
from operator import itemgetter
D, G = map(int, input().split())
p = []
c = []
score = 0
ans = 0
for i in range(D):
    pi, ci = map(int, input().split())
    p.append(pi)
    c.append(ci)
a = [i for i in range(D)]
comp = [[i, 100*(i+1)*p[i]+c[i], (100*(i+1)*p[i]+c[i])//p[i], p[i]] for i in range(D)]
comp.sort(key=itemgetter(2),reverse=True)
for d in range(D):
    if score + comp[d][1] < G:
        #print(comp[d][0])
        score += comp[d][1]
        a.pop(comp[d][0])
        ans += comp[d][3]
    else:
        can = d
        for dd in range(d,D):
            if score + comp[dd][1] >= G and comp[can][3] > comp[dd][3]:
                can = dd

        if 100*(max(a)+1)*p[max(a)] + score >= G and comp[can][3] >= (G-score-1)//(100*(max(a)+1)) + 1:
            #print(ans)
            ans += (G-score-1)//(100*(max(a)+1)) + 1
            #print(ans)
            break
        else:
            ans += comp[can][3]
            break
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import product
from math import ceil


def solve(string):
    d, g, *pc = map(int, string.split())
    g //= 100
    p = [_p for _p in pc[::2]]
    c = [_c // 100 for _c in pc[1::2]]
    ans = 1000
    for f in product([True, False], repeat=d):
        sums = sum([(i + 1) * _p + _c for i, (_f, _p, _c) in enumerate(zip(f, p, c)) if _f])
        counts = sum([_p for _f, _p in zip(f, p) if _f])
        if g <= sums:
            ans = min(ans, counts)
            continue

        indices = [i + 1 for i, _f in enumerate(f) if not _f]
        tmp = ceil((g - sums) / indices[-1])
        if tmp < p[indices[-1]]:
            ans = min(ans, counts + tmp)
    return str(ans)


if __name__ == '__main__':
    n, g = map(int, input().split())
    print(solve('{} {}\n'.format(n, g) + '\n'.join([input() for _ in range(n)])))

Submission status: Runtime Error

Solution code:
from math import ceil


def solve(string):
    d, g, *pc = map(int, string.split())
    g //= 100
    p = [_p for _p in pc[::2]]
    c = [_c // 100 for _c in pc[1::2]]
    ans = []
    eff_comp = [((_p * (i + 1) + _c) / _p, i + 1, _p, _c) for i, (_p, _c) in enumerate(zip(p, c))]
    eff_incomp = [(i + 1, i + 1, _p - 1, 0) for i, (_p, _c) in enumerate(zip(p, c))]

    eff = sorted(eff_comp + eff_incomp, reverse=True)
    tmp = 0
    used = []
    for _e, _i, _p, _c in eff:
        if _i in used:
            continue
        if _e * _p < g:
            g -= _i * _p + _c
            tmp += _p
            used.append(_i)
            continue
        if _c == 0:
            ans.append(tmp + (ceil(g / _e)))
        else:
            ans.append(tmp + _p)
    return str(min(ans))


if __name__ == '__main__':
    n, g = map(int, input().split())
    print(solve('{} {}\n'.format(n, g) + '\n'.join([input() for _ in range(n)])))
    print(solve(input()))

Submission status: Runtime Error

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())


def f(x):
    val = 0
    p_sum = 0
    bit = format(x, '0{}b'.format(D))
    for i in range(D):
        val += int(bit[i]) * (i + 1) * 100 * p[i] + int(bit[i]) * c[i]
        # print(val)
        p_sum += p[i] * int(bit[i])
    if not val >= G:
        # print('add more')
        for i in range(D):
            tmp = 0
            val_tmp = 0
            while val + val_tmp < G:
                val_tmp += abs(int(bit[- i - 1]) - 1) * (D - i) * 100
                tmp += 1
                if tmp == p[D - 1 - i]:
                    break
            else:
                p_sum += tmp
                val += val_tmp
                break
        else:
            p_sum += 1000000000

    # print(x, bit, p_sum, val)
    if x == 0:
        return p_sum
    else:
        return min(p_sum, f(x - 1))


# print('x', 'b ', 'p', 'val')
print(f(2 ** D - 1))

Submission status: Runtime Error

Solution code:
def solve(problem,l):
    re = []
    for i in range(len(l)):
        if i == problem:
            re.append(l[i] + 1)
        else:
            re.append(l[i])
    return re



D,G = (int(i) for i in input().split())  
p = []
c = []
for _ in range(D):
    p_t,c_t =  (int(i) for i in input().split())
    p.append(p_t)
    c.append(c_t)

state = []
for _ in range(1000):
    state.append([0] * (D + 1))

i = 0
for j in range(D):
    point = state[i][-1]
    if p[j] > state[i][j]:
        point += 100 * (j + 1) * (p[j] - state[i][j])
        point += c[j]

        if state[i + (p[j] - state[i][j])][-1] < point:
            new_state = state[i] 
            for _ in range(p[j] - state[i][j]):
                new_state = solve(j,new_state)
            state[i + (p[j] - state[i][j])] = new_state
            state[i + (p[j] - state[i][j])][-1] = point
i += 1
while(True):
     #最後だけ取れる得点
    problem = 0
    for j in range(D):
        point = state[i-1][-1]
        if p[j] > state[i-1][j]:
            point += 100 * (j + 1)
            if p[j] - state[i-1][j] == 1:
                point += c[j]

        if state[i][-1] < point:
            state[i] = solve(j,state[i-1])
            state[i][-1] = point
    #print(state[0:10])
    for j in range(D):
        point = state[i][-1]
        if p[j] > state[i][j]:
            point += 100 * (j + 1) * (p[j] - state[i][j])
            point += c[j]

            if state[i + (p[j] - state[i][j])][-1] < point:
                new_state = state[i] 
                for _ in range(p[j] - state[i][j]):
                    new_state = solve(j,new_state)
                state[i + (p[j] - state[i][j])] = new_state
                state[i + (p[j] - state[i][j])][-1] = point

    #print(state[0:10])
    if state[i][-1] >= G:
        #print(state)
        print(i)
        break
    i += 1

Submission status: Runtime Error

Solution code:
def solve(problem,l):
    re = []
    for i in range(len(l)):
        if i == problem:
            re.append(l[i] + 1)
        else:
            re.append(l[i])
    return re



D,G = (int(i) for i in input().split())  
p = []
c = []
for _ in range(D):
    p_t,c_t =  (int(i) for i in input().split())
    p.append(p_t)
    c.append(c_t)

state = []
for _ in range(250):
    state.append([0] * (D + 1))

i = 0
for j in range(D):
    point = state[i][-1]
    if p[j] > state[i][j]:
        point += 100 * (j + 1) * (p[j] - state[i][j])
        point += c[j]

        if state[i + (p[j] - state[i][j])][-1] < point:
            new_state = state[i] 
            for _ in range(p[j] - state[i][j]):
                new_state = solve(j,new_state)
            state[i + (p[j] - state[i][j])] = new_state
            state[i + (p[j] - state[i][j])][-1] = point
i += 1
while(True):
     #最後だけ取れる得点
    problem = 0
    for j in range(D):
        point = state[i-1][-1]
        if p[j] > state[i-1][j]:
            point += 100 * (j + 1)
            if p[j] - state[i-1][j] == 1:
                point += c[j]

        if state[i][-1] < point:
            state[i] = solve(j,state[i-1])
            state[i][-1] = point
    #print(state[0:10])
    for j in range(D):
        point = state[i][-1]
        if p[j] > state[i][j]:
            point += 100 * (j + 1) * (p[j] - state[i][j])
            point += c[j]

            if state[i + (p[j] - state[i][j])][-1] < point:
                new_state = state[i] 
                for _ in range(p[j] - state[i][j]):
                    new_state = solve(j,new_state)
                state[i + (p[j] - state[i][j])] = new_state
                state[i + (p[j] - state[i][j])][-1] = point

    #print(state[0:10])
    if state[i][-1] >= G:
        #print(state)
        print(i)
        break
    i += 1

Submission status: Runtime Error

Solution code:
import math
D, G = [int(i) for i in input().split()]
data_ls = list()
for i in range(D):
    data_ls.append([int(i) for i in input().split()])
ps, cs = zip(*data_ls)

def search(cnt, sum, flg, rest_max):
    if sum > G:
        return cnt
    if flg == len(data_ls):
        if sum + (ps[rest_max] - 1) * 100 * (rest_max + 1) >= G:
            return cnt + math.floor((G - sum) / (100 * (rest_max+1)))
        else:
            return 1e9
    cnt = min(search(cnt + ps[flg], sum + (ps[flg] * 100 * (flg+1) + cs[flg]), flg + 1, rest_max),
              search(cnt, sum, flg + 1, flg))
    return cnt

print(search(0,0,0,-1))

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
c=[0]+[list(map(int,input().split()))for i in range(a)]
def f(t,s):
    if t==0:
        return 10000007
    else:
        l=min(s//(t*100),c[t][0])
        k=100*i*l
        if n==c[t][0]:
            l+=s[t][1]
        if l<G:
            n+=f(t-1,s-l)
        return min(n,f(t-1,s))
print(f(a,b))

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
c=[0]+[list(map(int,input().split()))for i in range(n)]
def f(s,t):
    if t==0:
        return 10000007
    else:
        l=min(s//(i*100),c[i][0])
        k=100*i*l
        if n==c[i][0]:
            l+=s[i][1]
        if l<G:
            n+=f(s-l,i-1)
        return min(n,f(s,i-1))
print(f(b,a))

Submission status: Runtime Error

Solution code:
a,b=int(input())
c=[0]+[list(map(int,input().split()))for i in range(n)]
def f(s,t):
    if t==0:
        return 10000007
    else:
        l=min(s//(i*100),c[i][0])
        k=100*i*l
        if n==c[i][0]:
            l+=s[i][1]
        if l<G:
            n+=f(s-l,i-1)
        return min(n,f(s,i-1))
print(f(b,a))

Submission status: Runtime Error

Solution code:
#2-1-1 #ABC104C
d,g=map(int,input().split())
q=[]
comp=[]
bornus=[]
for i in range(d):
    p,c=map(int,input().split())
    q.append(p)
    bornus.append(100*(i+1)*p+c)
    comp.append((100*(i+1)*p+c)/p)
    
p=[100*i for i in range(1,d+1)]
    
data={0:[0 for i in range(d)]}
def makemax(p,q,bornus,comp,k):
    now=0
    point=0
    pnow=p.copy()
    qnow=q.copy()
    bornusnow=bornus.copy()
    compnow=comp.copy()
    while now<k:
        compnown=compnow.copy()
        kagen=max(pnow)
        kagenidx=pnow.index(kagen)
        kagen_num=qnow[kagenidx]
        for i in range(d):
            maxcomp=max(compnown)
            compnown.pop(compnow.index(maxcomp))
            maxidx=compnow.index(maxcomp)
            if maxcomp<kagen:break
            if qnow[maxidx]>k-now:continue
            point+=bornusnow[maxidx]
            now+=qnow[maxidx]
            compnow[maxidx]=0
            pnow[maxidx]=0
            if maxidx==kagenidx:
                if len(pnow)!=0:
                    kagen=max(pnow)
                    kagenidx=pnow.index(kagen)
                    kagen_num=qnow[kagenidx]
                else:
                    kagen=-1
        if kagen==-1:break
        adit=min(k-now,kagen_num)
        if adit==kagen_num:
            point+=bornusnow[kagenidx]
            now+=kagen_num
        elif adit<kagen_num:
            point+=adit*kagen
            now+=adit
        compnow[kagenidx]=0
        pnow[kagenidx]=0
    return point

ans=-1
k=0
while ans==-1:
    if makemax(p,q,bornus,comp,k)>=g:
        ans=k
        
    k+=1
print(ans)

Submission status: Runtime Error

Solution code:
#2-1-1 #ABC104C
d,g=map(int,input().split())
q=[]
comp=[]
bornus=[]
for i in range(d):
    p,c=map(int,input().split())
    q.append(p)
    bornus.append(100*(i+1)*p+c)
    comp.append((100*(i+1)*p+c)/p)
    
p=[100*i for i in range(1,d+1)]
    
data={0:[0 for i in range(d)]}
def makemax(p,q,bornus,comp,k):
    now=0
    point=0
    pnow=p.copy()
    qnow=q.copy()
    bornusnow=bornus.copy()
    compnow=comp.copy()
    while now<k:
        compnown=compnow.copy()
        kagen=max(pnow)
        kagenidx=pnow.index(kagen)
        kagen_num=qnow[kagenidx]
        for i in range(d):
            maxcomp=max(compnown)
            compnown.pop(compnow.index(maxcomp))
            maxidx=compnow.index(maxcomp)
            if maxcomp<kagen:break
            if qnow[maxidx]>k-now:continue
            point+=bornusnow[maxidx]
            now+=qnow[maxidx]
            compnow[maxidx]=0
            pnow[maxidx]=0
            if maxidx==kagenidx:
                kagen=max(pnow)
                kagenidx=pnow.index(kagen)
                kagen_num=qnow[kagenidx]
        adit=min(k-now,kagen_num)
        if adit==kagen_num:
            point+=bornusnow[kagenidx]
            now+=kagen_num
        elif adit<kagen_num:
            point+=adit*kagen
            now+=adit
        compnow[kagenidx]=0
        pnow[kagenidx]=0
    return point

ans=-1
k=0
while ans==-1:
    if makemax(p,q,bornus,comp,k)>=g:
        ans=k
        
    k+=1
print(ans)

Submission status: Runtime Error

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

for i in range(D):
    p,c = list(map(int,input().split()))
    P.append(p)
    C.append(c)

for c in range(2**D):
    score = 0
    solved = 0
    remain = []
    for i,b in enumerate(format(c,'b').zfill(D)):
        if b == '1':
            score += P[i]*100*(i+1) + C[i]
            solved += P[i]
        else:
            remain.append(i)
    if score < G:
        R = G - score
        j = remain[-1]
        if (P[j]-1)*(j+1)*100 < R:
            continue
        solved += (R//(100*(j+1)))
    ans = min(solved, ans)

print(ans)

Submission status: Runtime Error

Solution code:
import math
D, G = map(int, input().split())
L = []
for i in range(1, D+1):
    p, c = map(int, input().split())
    L.append([i, p, c])
L.sort(key=lambda x: (100*x[0]*x[1]+x[2])/x[1], reverse=True)
num = 0
for j in range(D):
    if G > 100*L[j][0]*L[j][1]+L[j][2]:
        G -= 100*L[j][0]*L[j][1]+L[j][2]
        num += L[j][1]
        L[j] = [0, 0, 0]
    else:
        tmp_num = L[j][1]
        break
M = L.sort(key=lambda x: x[0], reverse=True)
tmp_num = min(tmp_num, math.ceil(G/(100*M[0][0])))
print(num + tmp_num)