Problem:


Score : 300 points

Problem Statement

A programming competition site AtCode provides algorithmic problems.
Each problem is allocated a score based on its difficulty.
Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.
These p_1 + … + p_D problems are all of the problems available on AtCode.

A user of AtCode has a value called total score.
The total score of a user is the sum of the following two elements:

Base score: the sum of the scores of all problems solved by the user.

Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).

Takahashi, who is the new user of AtCode, has not solved any problem.
His objective is to have a total score of G or more points.
At least how many problems does he need to solve for this objective?

Constraints

1 ≤ D ≤ 10

1 ≤ p_i ≤ 100

100 ≤ c_i ≤ 10^6

100 ≤ G

All values in input are integers.

c_i and G are all multiples of 100.

It is possible to have a total score of G or more points.

Input

Input is given from Standard Input in the following format:

D G
p_1 c_1
:
p_D c_D

Output

Print the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).

Sample Input 1

2 700
3 500
5 800

Sample Output 1

3

In this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.

One way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.

Sample Input 2

2 2000
3 500
5 800

Sample Output 2

7

This case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.

Sample Input 3

2 400
3 500
5 800

Sample Output 3

2

This case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.

Sample Input 4

5 25000
20 1000
40 1000
50 1000
30 1000
1 1000

Sample Output 4

66

There is only one 500-point problem, but the perfect bonus can be earned even in such a case. 



Sample input:
2 700
3 500
5 800


Sample output:
3

Submission status: Wrong Answer

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

for i in range(len(pc)):
    pc[i].append((100 * (i+1) * pc[i][0] + pc[i][1]) / pc[i][0])
    pc[i].append(i+1)

pc = sorted(pc, key=lambda x: x[2], reverse=True)

ans = 0
del_list = []
for i, info in enumerate(pc):
    if (100 * info[3] * info[0] + info[1]) <= G:
        G -= (100 * info[3] * info[0] + info[1])
        ans += info[0]
        del_list.append(i)
    else:
        break

pc = [info for i, info in enumerate(pc) if i not in del_list]

pc = sorted(pc, key=lambda x: x[3], reverse=True)

while G > 0:
    G -= 100 * pc[0][3]
    pc[0][0] -= 1
    ans += 1
    if pc[0][0] == 0:
        G -= pc[0][1]
        pc.pop(0)

print(ans)

Submission status: Wrong Answer

Solution code:

d, g = map(int, input().strip().split())
points = [list(map(int, input().strip().split())) for _ in range(d)]

answer = float("inf")
for combination in range(2 ** d):
    score = 0
    solved = 0
    for difficuty in range(d):
        if (combination >> difficuty) & 1:
            score += points[difficuty][0] * 100 * (difficuty + 1) + points[difficuty][1]
            solved += points[difficuty][0]
    if score < g:
        for difficuty in range(d)[::-1]:
            if not (combination >> difficuty) & 1 and g - score < points[difficuty][0] * 100 * (difficuty + 1):
                solved += (g - score) // (100 * (difficuty + 1)) + 1
                break
        else:
            continue
    if answer > solved:
        answer = solved
print(answer)

Submission status: Wrong Answer

Solution code:
import copy
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())

print(g)
print(p[0], c)

#はじめどこから足すか決めてない
def SumScore(i, s, counter, l):
    global ans #ここが大切
    if counter[-1] != 0: #これはエラー処理で無視させる
        pass
    
    elif s >= g: #必ず総合スコアはg点以上になるから，これが停止条件
        if counter[-1] == 0:
            z = sum(counter[: d])
            ans = min(ans, z)
            return ans

    else:
        if d <= i: #indexの問題発生
            counter[-1] += 1
            return SumScore(i, s, counter, l)
        elif counter[i] == p[i]: #コンプリートボーナスを得る時，counterが限界に
            return SumScore(i + 1, s + c[i], counter, l)
        else: #コンプリートボーナスを得ない時
            #リストはこうやってコピーしないと変更を更新してしまう
            cp_counter = copy.copy(counter) #ここ初歩的だけどまじで困った
            x = SumScore(i + 1, s, cp_counter, l) #次に進む
            counter[i] += 1
            y = SumScore(i, s + (i + 1) * 100, counter, l) #素直に足す
            return x, y
    

ans = float("inf")
SumScore(0, 0, [0] * (d + 1), l = [])
print(ans)

Submission status: Wrong Answer

Solution code:
d,g=map(int,input().split())
pc={_:(list(map(int,input().split()))) for _ in range(d)}
bin_lst=[]
d2=2**d
for x in range(d2):
    buf=bin(x)[2:]
    len_buf=len(buf)
    if len_buf<d:
        buf='0'*(d-len_buf)+buf
    bin_lst.append(buf)
print(bin_lst)
lst_cnt=[]
buf_lst=[]
for x in bin_lst:
    cnt=0
    buf_int=0
    len_x=len(x)
    for y in range(d):
        if x[y]=="1":
            buf_lst=pc[y]
            buf_int+=(y+1)*100*buf_lst[0]+buf_lst[1]
            cnt+=buf_lst[0]
    if buf_int<g:
        buf_index=x.rfind("0")
        buf_lst=pc[buf_index]
        i=buf_lst[0]
        for z in range(1,i):
            if buf_int+(buf_index+1)*100*z>=g:
                buf_int+=(buf_index+1)*100*z
                cnt+=z
                break
    if buf_int>=g:
        lst_cnt.append(cnt)
print(min(lst_cnt))

Submission status: Wrong Answer

Solution code:
D,G = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(D)]
ans = 10**9
for i in range(2**D):
  score=0
  n=0
  done=""
  for j in range(D):
    if (i>>j)&1:
      score += 100*(j+1)*pc[j][0]+pc[j][1]
      n += pc[j][0]
      done+=str(j)
  if score < G:
    for k in range(D):
      if str(k) in done:
        continue
      for l in range(pc[D-k-1][0]):
        score += 100*(D-k)
        n += 1
        if score >= G:
          break
      if score >= G:
        break
  ans = min(ans,n)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])


def main():
    d,g=inpm()
    p,c,t=[],[],[]
    ans=10**5
    for i in range(d):
        x,y=inpm()
        p.append(x)
        c.append(y)
        t.append(x*(i+1)*100+y)
    for num in range(1,d+1):
        for groop in combinations(range(d),num):
            total = 0
            member = 0
            for e in groop:
                total += t[e]
                member += p[e]
            if total < g:
                continue
            notgroup = []
            for i in range(d):
                if i not in groop:
                    notgroup.append(i)
            max_e=-1
            if len(notgroup)>0:
                max_e = max(notgroup)
            if max_e == d-1 or max_e==-1:
                pre_ans = 0
                for i in groop:
                    pre_ans += p[i]
                ans = min(ans,pre_ans)
            if max_e!=d-1:
                for way in range(max_e+1,d):
                    if total - c[way] - (way+1)*100 <g:
                        continue
                    print(total,g,way)
                    diff = total - g - c[way] - (way+1)*100
                    pre_ans = member - 1 - min(p[way]-1,diff//((way+1)*100))
                    ans = min(ans,pre_ans)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])


def main():
    d,g=inpm()
    p,c,t=[],[],[]
    ans=10**5
    for i in range(d):
        x,y=inpm()
        p.append(x)
        c.append(y)
        t.append(x*(i+1)*100+y)
    for num in range(1,d+1):
        for groop in combinations(range(d),num):
            total = 0
            member = 0
            for e in groop:
                total += t[e]
                member += p[e]
            if total < g:
                continue
            notgroup = []
            for i in range(d):
                if i not in groop:
                    notgroup.append(i)
            max_e=-1
            if len(notgroup)>0:
                max_e = max(notgroup)
            if max_e == d-1:
                pre_ans = 0
                for i in groop:
                    pre_ans += p[i]
                ans = min(ans,pre_ans)
            else:
                for way in range(max_e+1,d):
                    if total - c[way] - (way+1)*100 <g:
                        continue
                    diff = total - g - c[way] - (way+1)*100
                    pre_ans = member - 1 - min(p[way]-1,diff//((way+1)*100))
                    ans = min(ans,pre_ans)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import itertools as it
import math as m

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

ans = 100 * 10
for i in it.product(range(2), repeat=D):
    now_score = 0
    now_prob = 0
    partial_solve = -1
    for ith_p in range(D):
        if i[ith_p] == 1:
            now_score += (ith_p + 1) * 100 * pc[ith_p][0] + pc[ith_p][1]
            now_prob += pc[ith_p][0]
        elif i[ith_p] == 0:
            partial_solve = ith_p

    if now_score >= G:
        ans = min(ans, now_prob)
    elif m.ceil(G - now_score) / ((partial_solve + 1) * 100) <= pc[partial_solve][0]:
        ans = min(ans, now_prob + m.ceil(G - now_score) / ((partial_solve + 1) * 100))
print(int(ans))

Submission status: Wrong Answer

Solution code:
import itertools as it
import math as m

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

ans = 100 * 10
for i in it.product(range(2), repeat=D):
    now_score = 0
    now_prob = 0
    max_0 = -1
    for ith_p in range(D):
        if i[ith_p] == 1:
            now_score += (ith_p + 1) * 100 * pc[ith_p][0] + pc[ith_p][1]
            now_prob += pc[ith_p][0]
        elif i[ith_p] == 0:
            max_0 = max(max_0, ith_p)

    if now_score >= G:
        ans = min(ans, now_prob)
    elif max_0 != -1 and m.ceil(G - now_score) / ((max_0 + 1) * 100) <= pc[max_0][0]:
        ans = min(ans, now_prob + m.ceil(G - now_score) / ((max_0 + 1) * 100))
print(int(ans))

Submission status: Wrong Answer

Solution code:
D,G = map(int,input().split())
PC = [list(map(int,input().split())) for _ in range(D)]
comp = [PC[i][0]*(i+1)*100+PC[i][1] for i in range(D)]
ans = float("inf")
for i in range(2**D):
    Gt = 0
    cnt = 0
    lis = [0]*D
    tmp = str(bin(i))[2:]
    for j in range(len(tmp)):
        lis[-j-1] = int(tmp[-j-1])
    for k in range(D):
        if lis[k]:
            Gt += comp[k]
            cnt += PC[k][0]
        else:
            hanpa = k
    if Gt>=G:
        ans = min(ans,cnt)
        continue
    if G-Gt > (PC[hanpa][0]-1)*(hanpa+1)*100:
        continue
    cnt += (G-Gt)//((hanpa+1)*100)
    ans = min(ans,cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
D,G = map(int,input().split())
PC = [list(map(int,input().split())) for _ in range(D)]
comp = [PC[i][0]*(i+1)*100+PC[i][1] for i in range(D)]
ans = float("inf")
for i in range(2**D):
    Gt = 0
    cnt = 0
    lis = [0]*D
    tmp = str(bin(i))[2:]
    for j in range(len(tmp)):
        lis[-j-1] = int(tmp[-j-1])
    for k in range(D):
        if lis[k]:
            Gt += comp[k]
            cnt += PC[k][0]
        else:
            hanpa = k
    if Gt>=G:
        ans = min(ans,cnt)
        continue
    if G-Gt > PC[hanpa][0]*(hanpa+1)*100:
        continue
    cnt += (G-Gt)//((hanpa+1)*100)
    ans = min(ans,cnt)
print(ans)

Submission status: Wrong Answer

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

ans = float('inf')
for i,p,c in re_PC:
    g = G
    cnt = 0
    for i,p,c in re_PC[i-1:]:
        n = min(g//(i*100),p)
        g -= i*100*n
        if p == n:
            g -= c
        cnt += n
        # print(n,g,cnt)
        if g <= 0:
            break
        if i == 1:
            cnt = float("inf")
    ans = min(ans,cnt)

print(ans)

Submission status: Wrong Answer

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

for i in range(2 ** D):
    a = 0
    b = 0
    for j in range(D):
        if (i >> j) & 1 :
            a += 100 * P[j] * (j + 1) + C[j]
            b += P[j]
    for k in range(D - 1, -1, -1):
        if (i >> k) & 1:
            continue
        if b >= G:
            break
        for l in range(P[k] + 1):
             a += 100 * (k + 1)
             b += 1
             if a >= G:
                 break
    ans = min(ans, b)
print(ans)

Submission status: Wrong Answer

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

for i in range(2 ** D):
    a = 0
    b = 0
    for j in range(D):
        if i >> j & 1 :
            a += 100 * P[j] * (j + 1) + C[j]
            b += P[j]
    for k in range(D - 1, -1, -1):
        if (i >> k) & 1:
            continue
        if b >= G:
            break
        for l in range(P[k] + 1):
             a += 100 * (k + 1)
             b += 1
             if a >= G:
                 break
    ans = min(ans, b)
print(ans)

Submission status: Wrong Answer

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

for i in range(2 ** D):
    a = 0
    b = 0
    for j in range(D):
        if i >> j & 1 :
            a += 100 * P[j] * (j + 1) + C[j]
            b += P[j]
    for k in range(D - 1, -1, -1):
        if (i >> k) & 1:
            continue
        if b >= G:
            break
        for l in range(P[k]):
             a += 100 * (k + 1)
             b += 1
             if a >= G:
                 break
    ans = min(ans, b)
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
D, G = map(int, input().split())
pc = []
for i in range(D):
    p, c = map(int, input().split())
    pc.append([p, c])
ans = 10**7
for i in range(2**D):
    tmp = 0
    cnt = 0
    rest = list(range(1, D+1))
    for j in range(D):
        if (i >> j) & 1 == 1:
            tmp += pc[j][0] * 100 * (j+1) + pc[j][1]
            cnt += pc[j][0]
            rest.remove(j+1)
    # print(rest)
    if tmp < G:
        plus = max(rest)
        n = min(pc[plus-1][0], abs((G-tmp) // (plus * 100)))
        cnt += n
        tmp += n * plus * 100
    if tmp >= G:
        ans = min(ans, cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
D, G = map(int, input().split())
pc = []
for i in range(D):
    p, c = map(int, input().split())
    pc.append([p, c])
ans = 1000000
for i in range(2**D):
    tmp = 0
    cnt = 0
    rest = list(range(1, D+1))
    for j in range(D):
        if (i >> j) & 1 == 1:
            tmp += pc[j][0] * 100 * (j+1) + pc[j][1]
            cnt += pc[j][0]
            rest.remove(j+1)
    # print(rest)
    if tmp < G:
        plus = max(rest)
        n = min(pc[plus-1][0], abs((G-tmp) // (plus * 100)))
        cnt += n
        tmp += n * plus * 100
    if tmp >= G:
        ans = min(ans, cnt)
print(ans)

Submission status: Wrong Answer

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

ans=100000

for i in range(2**D):
    ten=0
    mondaisu=0
    for j in range(D):
        if ((i>>j)&1):
            ten+=(j+1)*100*p[j]+c[j]
            mondaisu+=p[j]
        else:
            k=j
    if ten>G:
        if ans>mondaisu:
            ans=mondaisu
    else:
        if G-ten<=(k+1)*100*p[k]:
            mondaisu+=(G-ten-1)//(k+1)*100+1
            if ans>mondaisu:
                ans=mondaisu
print(ans)

Submission status: Wrong Answer

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

ans=100000

for i in range(2**D):
    ten=0
    mondaisu=0
    for j in range(D):
        if ((i>>j)&1):
            ten+=(j+1)*100*p[j]+c[j]
            mondaisu+=p[j]
        else:
            k=j
    if ten>=G:
        if ans>mondaisu:
            ans=mondaisu
    else:
        if G-ten<=(k+1)*100*p[k]:
            mondaisu+=(G-ten-1)//(k+1)*100+1
            if ans>mondaisu:
                ans=mondaisu
print(ans)

Submission status: Wrong Answer

Solution code:
D,G=map(int,input().split())
p=[]
c=[]
for i in range(D):
    a,b=map(int,input().split())
    p.append(a)
    c.append(b)
ten=0
mondaisu=0
ans=100000

for i in range(2**D):
    for j in range(D):
        if (i>>j)&1==1:
            ten+=(j+1)*100*p[j]+c[j]
            mondaisu+=p[j]
        else:
            k=j
    if ten>=G:
        if ans>mondaisu:
            ans=mondaisu
    else:
        if G-ten<=(k+1)*100*p[k]:
            mondaisu+=(G-ten-1)//(k+1)*100+1
            if ans>mondaisu:
                ans=mondaisu
print(ans)

Submission status: Wrong Answer

Solution code:
D,G=map(int,input().split())
p=[]
c=[]
for i in range(D):
    a,b=map(int,input().split())
    p.append(a)
    c.append(b)
ten=0
mondaisu=0
ans=100000

for i in range(2**D):
    for j in range(D):
        if ((i>>j)&1):
            ten+=(j+1)*100*p[j]+c[j]
            mondaisu+=p[j]
        else:
            k=j
    if ten>=G:
        if ans>mondaisu:
            ans=mondaisu
    else:
        if G-ten<=(k+1)*100*p[k]:
            mondaisu+=(G-ten-1)//(k+1)*100+1
            if ans>mondaisu:
                ans=mondaisu
print(ans)

Submission status: Wrong Answer

Solution code:
D,G=map(int,input().split())
p=[]
c=[]
for i in range(D):
    a,b=map(int,input().split())
    p.append(a)
    c.append(b)
sum=0
cnt=[]
for i in range(D):
    for j in range(2**p[i]):
        for k in range(p[i]):
            if ((j>>k)&1):
                sum+=100*i
                if j==2**p[i]-1:
                    sum+=c[i]
        if sum>=D:
            cnt.append(bin(j).count("1"))
print(min(cnt))

Submission status: Wrong Answer

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

total = 0
cnt = 0

p_max = n
tmp = n

for i in range(n):
    #現在最も高難度の問題を選定
    for j in reversed(range(n)):
        if p[p_max-1][0] == 0:
            p_max-=1
        else:
            break

    # 解く問題を決定
    tmp = p_max
    for j in range(p_max):
        # 問題をすべて解き終わっていたら、次の難易度へ
        if p[j][0] == 0:
            continue
            
        if tmp != p_max and ((j+1)*100 + p[j][1]/p[j][0]) > (tmp*100 + p[tmp-1][1]/p[tmp-1][0]) and g >= total + (p_max*100 * p[j][0]-1):
            tmp = j+1
            break
            
        # ボーナス考慮した点数が最高難度より高い & 個数-1個最高難度を解いた時に、まだ合計に達していない
        if p_max*100 <= ((j+1)*100 + p[j][1]/p[j][0]) and g >= total + (p_max*100 * p[j][0]-1):
            tmp = j+1
            
            
    #問題を解く
    for j in range(p[tmp-1][0]):
        total+=tmp*100
        cnt+=1
        p[tmp-1][0]-=1
        if total >= g:
            break
    else:
        total+=p[tmp-1][1]
        
    if total >= g:
        break
    
print(cnt)

Submission status: Wrong Answer

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

total = 0
cnt = 0

p_max = n
tmp = n

for i in range(n):
    #現在最も高難度の問題を選定
    for j in reversed(range(n)):
        if p[p_max-1][0] == 0:
            p_max-=1
        else:
            break

    # 解く問題を決定
    tmp = p_max
    for j in range(p_max):
        # 問題をすべて解き終わっていたら、次の難易度へ
        if p[j][0] == 0:
            continue
            
        if tmp != p_max and ((j+1)*100 + p[j][1]/p[j][0]) > ((tmp-1+1)*100 + p[tmp-1][1]/p[tmp-1][0]) and p[j][0] <= p[tmp-1][0]:
            tmp = j+1
            break
            
        # ボーナス考慮した点数が最高難度より高い & 個数-1個最高難度を解いた時に、まだ合計に達していない
        if p_max*100 <= ((j+1)*100 + p[j][1]/p[j][0]) and g >= total + (p_max*100 * p[j][0]-1):
            tmp = j+1
            
            
    #問題を解く
    for j in range(p[tmp-1][0]):
        total+=tmp*100
        cnt+=1
        p[tmp-1][0]-=1
        if total >= g:
            break
    else:
        total+=p[tmp-1][1]
        
    if total >= g:
        break
    
print(cnt)

Submission status: Wrong Answer

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

total = 0
cnt = 0

p_max = n
tmp = n

for i in range(n):
    #現在最も高難度の問題を選定
    for j in reversed(range(n)):
        if p[p_max-1][0] == 0:
            p_max-=1
        else:
            break

    # 解く問題を決定
    tmp = p_max
    for j in range(p_max):
        # 問題をすべて解き終わっていたら、次の難易度へ
        if p[j][0] == 0:
            continue
        # ボーナス考慮した点数が最高難度より高い & 個数-1個最高難度を解いた時に、まだ合計に達していない
        if p_max*100 <= ((j+1)*100 + p[j][1]/p[j][0]) and g >= total + (p_max*100 * p[j][0]-1):
            tmp = j+1
            
        if tmp != p_max and ((j+1)*100 + p[j][1]/p[j][0]) > ((tmp-1+1)*100 + p[tmp-1][1]/p[tmp-1][0]) and p[j][0] <= p[tmp-1][0]:
            tmp = j+1
            
    #問題を解く
    for j in range(p[tmp-1][0]):
        total+=tmp*100
        cnt+=1
        p[tmp-1][0]-=1
        if total >= g:
            break
    else:
        total+=p[tmp-1][1]
        
    if total >= g:
        break
    
print(cnt)

Submission status: Wrong Answer

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

total = 0
cnt = 0

p_max = n
tmp = n

for i in range(n):
    #現在最も高難度の問題を選定
    for j in reversed(range(n)):
        if p[p_max-1][0] == 0:
            p_max-=1
        else:
            break

    # 解く問題を決定
    tmp = p_max
    for j in range(p_max):
        # 問題をすべて解き終わっていたら、次の難易度へ
        if p[j][0] == 0:
            continue
        # ボーナス考慮した点数が最高難度より高い & 個数-1個最高難度を解いた時に、まだ合計に達していない
        if p_max*100 <= ((j+1)*100 + p[j][1]/p[j][0]) and g >= total + (p_max*100 * p[j][0]-1):
            tmp = j+1
            
    #問題を解く
    for j in range(p[tmp-1][0]):
        total+=tmp*100
        cnt+=1
        p[tmp-1][0]-=1
        if total >= g:
            break
    else:
        total+=p[tmp-1][1]
        
    if total >= g:
        break
    
print(cnt)

Submission status: Wrong Answer

Solution code:
#各配点の問題について、全て解くor全く解かないを決める
#点数に満たない場合は、配点のうち最も高いものを足りない分解く

d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]
ans = 10 ** 10

#まずはbitの列挙、一つずつ探索する
for bit in range(1<<d):
    count = 0
    sum = 0
    #残った配点を列挙するためにsetを用意しておく
    nokori = set(range(1,d+1))

    for i in range(d):
        #各bitが1の場合は解く, i=0は一桁目=1問目を見ている
        if ((bit<<i)&1) == 1:
            sum += pc[i][0] * (100*(i+1)) + pc[i][1]
            count += pc[i][0]
            #set.discard('x')で集合から'x'を削除する
            #i=0 -> 1桁目 -> discard(i+1), set(1, ..., d)
            nokori.discard(i+1)

    #合計sumが求めるgに達していない場合の処理をする
    #足すのは最大のものだけ、それ以外の場合は他のbitで処理
    #sumがgに足りないときはansに入れない
    if sum < g:
        #用いるのは、nokori集合の配点が最大のもの
        use = max(nokori)
        #解く問題数nを設定する
        #(g-sum): 必要な点数、use*100: 1問あたりの点数、切り上げて求める。最大はpi
        n = min(pc[use-1][0], -(-(g-sum)//(use*100)))
        count += n
        sum += n * use * 100
    #sumがgを超えた場合だけ、ansと比較する
    if sum >= g:
        ans = min(ans, count)

print(ans)

Submission status: Wrong Answer

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

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def calc(d, mask, probs, g):
    score = 0
    ret = 0
    flags = [mask & (1<<i) for i in range(d)]
    for i in range(d):
        val = (i+1)*100
        p = probs[i][0]
        c = probs[i][1]
        if flags[i]:
            ret += p
            score += c+p*val
    if g <= score:
        return ret
    for i in range(d, -1, -1):
        val = i*100
        p = probs[i-1][0]
        c = probs[i-1][1]
        if flags[i-1]:
            continue
        else:
            if (g - score) > val*(p-1):
                score += val*(p-1)
                ret += p-1
            else:
                np = (g-score+val-1)//val
                score += val*np
                ret += np
                break
    return ret

def main():
    d, g = rli()
    probs = []
    # print(list(range(10, 0, -1)))
    # print(7&5)
    # return
    for i in range(d):
        p, c = rli()
        probs.append([p, c])
    ans = -1
    for i in range(2**d):
        ret = calc(d, i, probs, g)
        if ans == -1:
            ans = ret
        else:
            ans = min(ans, ret)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def func(i,g,cnt):
	if not g:
		return cnt
	elif i < 0:
		return float('inf')

	cur_cnt = g//((i+1)*100)
	if g % (i+1)*100:
		cur_cnt += 1
	cur_cnt = min(cur_cnt,PC[i][0])
	g -= (i+1)*100*cur_cnt
	if cur_cnt == PC[i][0]:
		# print(str(i+1)+'ボーナス',PC[i][1],g)
		g -= PC[i][1]
	# print(g,cnt+cur_cnt)
	cnt = func(i-1,g,cnt+cur_cnt)
	return cnt


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

ans = [func(i,G,0) for i in range(D)]
print(min(ans))

Submission status: Wrong Answer

Solution code:
import math
D, G = [int(x) for x in input().split()]
PC = [[int(x) for x in input().split()] for _ in range(D)]
ans = 100100
for i in range(2**D):
    cnt = 0
    point = 0
    for j in range(D):
        if (i >> j) & 1:
            cnt += PC[j][0]
            point += 100 * (j+1) * PC[j][0] + PC[j][1]
    if (point < G):
        rest = G-point
        for j in range(D)[::-1]:
            if (i >> j) & 1 == 0:
                if (rest < 100*(j+1)*PC[j][0]):
                    # 200点問題3問で500点
                    cnt += math.floor(rest / (100*(j+1)))
                    break 
                else:
                    cnt = 100100
                    break
    ans = min(ans, cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
D, G = [int(x) for x in input().split()]
PC = [[int(x) for x in input().split()] for _ in range(D)]
ans = 100100
for i in range(2**D):
    cnt = 0
    point = 0
    for j in range(D):
        if (i >> j) & 1:
            cnt += PC[j][0]
            point += 100 * (j+1) * PC[j][0] + PC[j][1]
    if (point < G):
        rest = G-point
        for j in range(D)[::-1]:
            if (i >> j) & 1 == 0:
                if (rest < 100*(j+1)*PC[j][0]):
                    # 200点問題3問で500点
                    cnt += (rest+99) // (100*(j+1))
                    break 
                else:
                    cnt = 100100
                    break
    ans = min(ans, cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
D, G = [int(x) for x in input().split()]
PC = [[int(x) for x in input().split()] for _ in range(D)]
ans = 100100
for i in range(2**D):
    cnt = 0
    point = 0
    for j in range(D):
        if i >> j & 1:
            cnt += PC[j][0]
            point += 100 * (j+1) * PC[j][0] + PC[j][1]
    if (point < G):
        rest = G-point
        for j in range(D)[::-1]:
            if i >> j & 1 == 0:
                if (rest <= 100*(j+1)*(PC[j][0]-1)):
                    # 200点問題3問で500点
                    cnt += (rest+99) // (100*(j+1))
                    break 
                else:
                    cnt = 100100
                    break
    ans = min(ans, cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
D, G = [int(x) for x in input().split()]
PC = [[int(x) for x in input().split()] for _ in range(D)]
ans = 100100
for i in range(2**D):
    cnt = 0
    point = 0
    for j in range(D):
        if i >> j & 1:
            cnt += PC[j][0]
            point += 100 * (j+1) * PC[j][0] + PC[j][1]
    if (point < G):
        rest = G-point
        for j in range(D)[::-1]:
            if i >> j & 1 == 0:
                if (rest < 100*(j+1)*PC[j][0]):                   # 200点問題3問で500点
                    cnt += (rest+99) // (100*(j+1))
                    break 
                else:
                    cnt = 100100
                    break
    ans = min(ans, cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
D, G = [int(x) for x in input().split()]
PC = [[int(x) for x in input().split()] for _ in range(D)]
ans = 100100
for i in range(2**D):
    cnt = 0
    point = 0
    for j in range(D):
        if i >> j & 1:
            cnt += PC[j][0]
            point += 100 * (j+1) * PC[j][0] + PC[j][1]
    if (point < G):
        for j in range(D)[::-1]:
            if i >> j ^ 1:
                cnt += (G-point+99) // (100*(j+1))
                break 
    ans = min(ans, cnt)
print(ans)

Submission status: Wrong Answer

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

i=d
c=0
while g>0:
  if g > p[i-1][0]*i*100 + p[i-1][1]:
    g -= p[i-1][0]*i*100 + p[i-1][1]
    c += p[i-1][0]
  else:
    t = (g+100*i-1)//(100*i)
    j = i-2
    x = i-1
    m = t
    while j >= 0:
      if p[j][0] < t and p[j][0]*(j+1)*100+p[j][1] >= g:
        if p[j][0]<m:
          x,m = j,p[j][0]
      j -= 1
    if x!=i-1:
      g -= p[x][0]*(x+1)*100+p[x][1]
      c += p[x][0]
      t = (g+100*i-1)//(100*i)
    g -= i*100*t
    c += t
  i -= 1

print(c)