#C8828. Minimum Retrieval Actions
Minimum Retrieval Actions
Minimum Retrieval Actions
You are given a series of taco orders. Each order has a certain quantity and a size. A retrieval action corresponds to picking up all orders of the same size in one go. Your task is to determine the minimum number of retrieval actions required to fulfill all orders.
Formally, let there be m orders. Although each order provides a quantity, only the size matters. Let \( S \) be the set of unique sizes from all orders. The answer is the number of elements in \( S \), i.e., \(|S|\).
Input/Output: The input is read from stdin
and the answer is printed to stdout
.
inputFormat
The first line contains an integer m, representing the number of orders. The second line contains m integers, where the i-th integer represents the quantity for the i-th order (this value is provided but not used in the calculation). The third line contains m strings, each representing the size of the i-th order. The sizes are separated by spaces.
Example:
4 3 4 2 5 S M S M
outputFormat
Output a single integer corresponding to the minimum number of retrieval actions required. This integer is equal to the number of distinct sizes among the orders.
Example:
2## sample
4
3 4 2 5
S M S M
2