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

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)

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)

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)
cnt = 10 ** 5
for i in range(2**d):
    tmp = 0
    ans = 0
    for j in range(d):
        if i >> j & 1:
            tmp += p[j]
            ans += c[j] + p[j] * 100 * (j + 1)
    for j in range(d-1, -1, -1):
        if ans >= g:
            break
        if i >> j & 1:
            continue
        for k in range(p[j] - 1):
            ans += 100 * (j + 1)
            tmp += 1
            if ans >= g:
                break
    if ans >= g:
        cnt = min (tmp, cnt)
print(cnt)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted