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):
D, G = map(int, input().split())

question_list = []

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


ans = 10 ** 5

for i in range(D): 
    others = D - 1

    for j in range(2 ** others): 
        bit = format(j, "0" + str(D) + "b")
        total = 0
        num_q = 0
        for k in range(D):
            if k == i:
                continue
            if bit[k] == "1":
                total += question_list[k][0] * 100 * (k + 1) + question_list[k][1]
                num_q += question_list[k][0]
        
        res = max(0, G - total)
        if res > 0: 
            res_q = res // (100 * (i + 1)) + (1 if res % (100 * (i+1)) != 0 else 0)
            if res_q > question_list[i][0]: 
                continue
            num_q += res_q
        
        ans = min(ans, num_q)

print(ans)

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

question_list = []

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


ans = 10 ** 5

for i in range(D): 
    others = D - 1

    for j in range(2 ** others): 
        bit = format(j, "0" + str(D) + "b")
        total = 0
        num_q = 0
        for k in range(D):
            if k == i:
                continue
            if bit[k] == "1":
                total += question_list[k][0] * 100 * (k + 1) + question_list[k][1]
                num_q += question_list[k][0]
        
        res = max(0, G - total)
        if res > 0: 
            res_q = int(res / (100 * (i + 1)) + 0.5)
            if res_q > question_list[i][0]: 
                continue
            num_q += res_q
        
        ans = min(ans, num_q)

print(ans)

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

question_list = []

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


ans = 10 ** 5

for i in range(D): 
    others = D - 1

    for j in range(2 ** others): 
        bit = format(j, "0" + str(D) + "b")
        total = 0
        num_q = 0
        for k in range(D):
            if k == i:
                continue
            if bit[k] == "1":
                total += question_list[k][0] * 100 * (k + 1) + question_list[k][1]
                num_q += question_list[k][0]
        
        res = max(0, G - total)
        res_q = 0
        if res > 0: 
            res_q = res // (100 * (i + 1)) + (1 if res % (100 * (i + 1)) > 0 else 0)
            if res_q > question_list[i][0]: 
                continue
            num_q += res_q
        
        ans = min(ans, num_q)

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

question_list = []

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


ans = 10 ** 5

for i in range(2 ** D):
    bit = format(i, "0" + str(D) + "b") 

    total = 0
    num_q = 0
    for j in range(len(bit)):
        if bit[j] == "1":
            total += question_list[j][0] * 100 * (j + 1) + question_list[j][1]
            num_q += question_list[j][0]
    
    res = max(0, G - total)

    if res > 0:
        ind = bit.rfind("0")
        res_q = res // (100 * (ind + 1)) + (1 if (res % (100 * (ind + 1)) != 0) else 0)
        if res_q > question_list[ind][0]:
            continue
        num_q += res_q
    
    ans = min(ans, num_q)

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted