#P8611. [蓝桥杯 2014 省 AB] 蚂蚁感冒
[蓝桥杯 2014 省 AB] 蚂蚁感冒
Description
There are ants on a thin straight rod of length cm. Some ants are facing left, and some are facing right.
Each ant can only crawl forward along the rod at a speed of cm/s.
When two ants meet, they will both turn around and crawl in the opposite directions.
Among these ants, one ant has caught a flu. When it meets other ants, it will infect the ant it touches.
Please compute how many ants will have the flu when all ants have crawled off the rod.
Input Format
The first line contains an integer , representing the total number of ants.
The next line contains integers separated by spaces. The absolute value of indicates the distance from the ant to the left end of the rod. A positive value means the ant is facing right, and a negative value means it is facing left. The input will not contain , and no two ants will be at the same position. The ant represented by the first number is the one that has the flu.
Output Format
Output one integer, representing the final number of ants that have the flu.
3
5 -2 8
1
5
-10 8 -20 12 25
3
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号