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):
import math
D, G = map(int, input().split())
P = []
C = []
for i in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)

used = [False for i in range(D)]


def check_goal(P, C, rest):
    result = []
    for i in range(len(P)):
        if used:
            continue
        if rest < 100 * (i + 1) * P[i]:
            result.append(math.ceil(rest // 100 * (i + 1)))
        elif rest <= 100 * (i + 1) * P[i] + C[i]:
            result.append(P[i])
        else:
            result.append(float("inf"))
    return result


def get_scores_best(P, C, rest):
    scores = [(100 * (i + 1), i) if 100 * (i + 1) * P[i] > rest else (100 *
                                                                      (i + 1) + C[i] / P[i], i) for i in range(len(P))]
    scores.sort(key=lambda x: x[0])
    scores.reverse()
    while True:
        j = 0
        if used[scores[j][1]]:
            j += 1
            continue
        else:
            return scores[j]


def judge(P, C, G):
    rest = G
    count = 0
    while True:
        count_list = check_goal(P, C, rest)
        if min(count_list) != float("inf"):
            count += min(count_list)
            return count
        else:
            score, i = get_scores_best(P, C, rest)
            count += P[i]
            rest -= 100 * (i + 1) * P[i] + C[i]
            print(rest)
            used[i] = True


print(judge(P, C, G))


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


def bit_search(A):
    result = []
    for i in range(1 << len(A)):
        output = []
        for j in range(len(A)):
            if ((i >> j) & 1) == 1:
                output.append(A[j])
        result.append(output)

    return result


search_list = bit_search(list(range(D)))
ans = 10 ** 9
for complete_list in search_list:
    score = sum([100 * (i + 1) * P[i] + C[i] for i in complete_list])
    count = sum([P[i] for i in complete_list])
    if score >= G:
        ans = min(ans, count)
    else:
        j_max = max([i for i in range(D) if i not in complete_list])
        required = -(-(G - score) // (100 * (j_max + 1)))
        if required < P[j_max]:
            count += required
            ans = min(ans, count)
print(ans)


Verdicts: Runtime Error

Accepted