Problem: 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?

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

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

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

print(ans)

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

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

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

print(ans)

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

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

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

print(ans)


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

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

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

print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted