NOI Contest Archive

Archive / 2024 / Qualifier Round

The Candy Shop Conundrum

Medium · NOI 2024 Qualifier Round

Storyline

You run a charming candy shop known for its 12 unique flavors of handcrafted sweets. Each flavor comes in a different colored wrapper, numbered 1 to 12. Business is booming, and you’ve just received a large order

You have several empty candy packets, each capable of holding up to 10 pieces of candy. Your customers are picky, and they much prefer packets containing only a single flavor of candy (a “single-flavor” packet). However, you may not have enough packets to make every packet single-flavor.

Challenge

Given the number of candy packets you have (P), and the quantity of each flavor (F[1] through F[12]), figure out the smallest possible number of packets that will end up containing multiple flavors (“mix-flavor” packets).

F = [7,24,…,11]

Calculate this minimum number of mix-flavor packets for a given number of packets (P) and candy quantities (F[1,2,..12]).

Input Format

Output Format

Constraints

Sample Input 0

8
1 2 3 4 5 6 7 8 9 10 11 12

Sample Output 0

4