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 itertools

def all_comb(iterable):
    for i in range(0, len(iterable) + 1):
        comb = itertools.combinations(iterable, i)
        for pair in comb:
            yield(pair)

def min_solve(goal_point, solve, pc_list):
    solve_point = sum([pc[0] * pc[2] + pc[1] for pc in solve])
    solve_num = sum([pc[0] for pc in solve])
    nc_solve = set(pc_list) - set(solve)
    if solve_point > goal_point:
        return float('Inf')
    if solve_point == goal_point:
        return solve_num
    nc_solve_max = max(nc_solve, key=lambda pc:pc[2])
    if solve_point + (nc_solve_max[0] - 1) * nc_solve_max[2]  >= goal_point:
	min_solve = int((goal_point - solve_point) / nc_solve_max[2] + solve_num)
        return min_solve
    else:
        return float('Inf')

if __name__=='__main__':
    D, G = map(int, input().split())
    pc_list = []
    for i in range(D):
	(p, c) = map(int, input().split())
	pc_list.append((p, c, (i + 1) * 100))
    min_num = min([min_solve(G, solve, pc_list) for solve in all_comb(pc_list)])
    print(min_num)


#!/usr/bin/python3                                                                                                                                                     

import itertools
import sys

def printe(value):
    print(value, file=sys.stderr)

def all_comb(iterable):
    for i in range(0, len(iterable) + 1):
        comb = itertools.combinations(iterable, i)
        for pair in comb:
            yield(pair)

def min_solve(goal_point, solve, pc_list):
    solve_point = sum([pc[0] * pc[2] + pc[1] for pc in solve])
    solve_num = sum([pc[0] for pc in solve])
    printe("solve={}".format(solve))
    printe("solve_point={}".format(solve_point))
    printe("solve_num={}".format(solve_num))

    nc_solve = set(pc_list) - set(solve)
    if solve_point > goal_point:
        return float('Inf')
    if solve_point == goal_point:
	return solve_num
    nc_solve_max = max(nc_solve, key=lambda pc:pc[2])
    if solve_point + (nc_solve_max[0] - 1) * nc_solve_max[2]  >= goal_point:
	min_solve = int((goal_point - solve_point) / nc_solve_max[2] + solve_num)
        return min_solve
    else:
        return float('Inf')

if __name__=='__main__':
    D, G = map(int, input().split())
    pc_list = []
    for i in range(D):
	(p, c) = map(int, input().split())
	pc_list.append((p, c, (i + 1) * 100))
    min_num = min([min_solve(G, solve, pc_list) for solve in all_comb(pc_list)])
    print(min_num)


import itertools
import math

def all_comb(iterable):
    for i in range(0, len(iterable) + 1):
        comb = itertools.combinations(iterable, i)
        for pair in comb:
            yield(pair)

def min_solve(goal_point, solve, pc_list):
    solve_point = sum([pc[0] * pc[2] + pc[1] for pc in solve])
    solve_num = sum([pc[0] for pc in solve])
    nc_solve = set(pc_list) - set(solve)
    if solve_point >= goal_point:
        return solve_num
    nc_solve_max = max(nc_solve, key=lambda pc:pc[2])
    if solve_point + (nc_solve_max[0] - 1) * nc_solve_max[2]  >= goal_point:
        min_solve = int(math.ceil((goal_point - solve_point) / nc_solve_max[2] + solve_num))
        return min_solve
    else:
        return float('Inf')

if __name__=='__main__':
    D, G = map(int, input().split())
    pc_list = []
    for i in range(D):
        (p, c) = map(int, input().split())
        pc_list.append((p, c, (i + 1) * 100))
    min_num = min([min_solve(G, solve, pc_list) for solve in all_comb(pc_list)])
    print(min_num)


Verdicts: Runtime Error

Runtime Error

Accepted