Cut Ribbon Problem

Cut Ribbon Problem — ExecCode Medium DSA Practice

Solve the Cut Ribbon problem on ExecCode. Free online medium DSA practice in DP. Write and run code in Java, C++, Python — no signup required to run.

Problem description

A ribbon has length n. Every piece you cut must have length a, b, or c. Return the maximum number of pieces. At least one way to cut the ribbon exactly is guaranteed. You are given: n — n piecea — piecea pieceb — pieceb piecec — piecec Return the maximum number of pieces. Copied from OA Lab Part 1.

Examples

Input {'n': 5, 'piecea': 5, 'pieceb': 3, 'piecec': 2}; Output 2. Input {'n': 7, 'piecea': 5, 'pieceb': 2, 'piecec': 5}; Output 2. Input {'n': 7, 'piecea': 5, 'pieceb': 5, 'piece_c': 2}; Output 2

Constraints

Follow the statement. Use a 64-bit integer when values can overflow.

Practice Cut Ribbon free on ExecCode. Browse DSA problems, topic map, and placement guides.