FastPrepMacaron Order Price

Macaron Order Price

OpenAI logoOpenAI● MediumFULLTIMEOA

Problem statement

A baker sells macarons with at most five distinct flavors. Every macaron has the same unit price. You are given quantities, where quantities[i] is the number of macarons of the i-th distinct flavor in an order, and an integer unitPrice in whole currency units.

The baker packs the order into sets. Each set contains at most five macarons and at most one macaron of any flavor. To fill each set as much as possible, the baker repeatedly takes one macaron from every flavor that still has a positive quantity, then starts the next set. The order of flavors within a set and the order of the completed sets do not matter.

The problem statement continues
Pro

Examples

Example 1

quantities = [2,2,1,1,1]unitPrice = 10return = 4800

The first set has five flavors and costs 5 × 10 × 0.6 = 30 currency units. The second has two flavors and costs 2 × 10 × 0.9 = 18. The total is 48 units, so return 4800.

Original screenshot from the interview report
Pro
FastPrep Pro
Reported in 1 OpenAI interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
See OpenAI hiring insights
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 OpenAI interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week