Balls
Easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
In a computer game, a player puts in a line of balls of different colors. When formed by a continuous chain of three or more balls of one color, it is removed from the line. All the balls at the same time shift to each other, and the situation could happen again.
Write a program that in this situation, determine how many balls will now be destroyed. Of course, continuous strings of three or more same color balls in the initial time may be no more than one.
Input
iven the number of balls in the chain (not more 1000) and the color of the balls (from 0 to 9, each color corresponds to a whole number).
Output
You want to display the number of balls that will be destroyed.
Examples
Input #1
Answer #1
Submissions 1K
Acceptance rate 27%