P2530 [SHOI2001] Chemical Plant Packer
Description
Factory No. 118 is the world’s only secret chemical plant that refines californium. Because refining californium is very difficult and the technology is not very mature, the finished products may have $3$ different purities: $A$: $100\%$, $B$: $1\%$, $C$: $0.01\%$. For convenient sale, products of different purities must be boxed separately. The packer Grant first takes $10$ products from the assembly line in order (if there are fewer than $10$ in total, he takes all of them). After that, each time he puts all products of one purity in his hand into the corresponding box, and then takes products from the assembly line in order so that he again holds $10$ products (if taking all the remaining ones still makes fewer than $10$, he takes all of them). If all the products have been boxed, then Grant’s task is finished.
Since boxing is very tiring, Grant hopes he can finish his task with the fewest number of boxing operations. Now he asks you to write a program to help him.
Input Format
The first line is $n$ ( $1\le n\le 100$ ), the number of products.
Then $n$ lines follow, each containing one uppercase letter $\texttt A$, $\texttt B$ or $\texttt C$, indicating the product’s purity.
Output Format
A single line containing the minimum number of boxing operations Grant needs.
Explanation/Hint
Translated by ChatGPT 5