[Huawei OD Unified Exam B Paper | 200 points] Unhappy children (C++ Java JavaScript python)

Huawei OD Online OJ:

Users who have already purchased this column, please private message the blogger to open an account and brush up questions online! ! !

Online OJ: brush the questions immediately

Question bank column: 2023 Huawei OD machine test (A volume + B volume) (C++JavaJSPy)

Topic: unhappy children

A batch of rocking cars have been added to the playground, which are very popular with children, but each rocking car can only be used by one child at a time. If there are no free rocking cars, you need to wait in line, or leave directly, and there is no one to play in the end. Children will be very unhappy.
Please count the number of unhappy children according to the coming and going of the children today.
1. The number of rocking cars is N, and the range is: 1 <= N < 10;
2. Each child corresponds to a code, and the code is a non-repeating number , The coming and going of children today can be coded as: 1 1 2 3 2 3. (If the child has a free rocking car before leaving, it means that he will leave after playing; the situation that the child has played many times is not considered). Number of children ≤ 100

3. The title ensures that all input data is normal and the range meets the above description

enter description

The first line: the number of rocking cars

The second line: the situation of children coming and going

output description

Return the number of unhappy children

Use case 1:

enter

 1  
 1 2 1 2  

output

 0 

Guess you like

Origin blog.csdn.net/shangyanaf/article/details/132641778