Tap here to switch tabs
Problem
Submissions

Problem: Cutting Ribbons

Cutting Ribbons asks for the greatest positive integer length that can be used to cut at least k identical ribbon segments from an array of ribbons, or zero if this is impossible.

Statement

You are given an integer array ribbons where each element represents the length of a ribbon, and an integer k. You are allowed to cut any ribbon into any number of positive integer length segments, or leave it uncut.

Return the maximum possible positive integer length of ribbon segments such that you can obtain at least k ribbons of that identical length. If it is impossible to obtain at least k ribbons of the same positive integer length, return 00.

Constraints:

  • 1≤1 \leq ribbons.length ≤105\leq 10^5

  • 1≤1 \leq ribbons[i] ≤105\leq 10^5

  • 1≤1 \leq k ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Cutting Ribbons

Cutting Ribbons asks for the greatest positive integer length that can be used to cut at least k identical ribbon segments from an array of ribbons, or zero if this is impossible.

Statement

You are given an integer array ribbons where each element represents the length of a ribbon, and an integer k. You are allowed to cut any ribbon into any number of positive integer length segments, or leave it uncut.

Return the maximum possible positive integer length of ribbon segments such that you can obtain at least k ribbons of that identical length. If it is impossible to obtain at least k ribbons of the same positive integer length, return 00.

Constraints:

  • 1≤1 \leq ribbons.length ≤105\leq 10^5

  • 1≤1 \leq ribbons[i] ≤105\leq 10^5

  • 1≤1 \leq k ≤109\leq 10^9