|
||||||||||
Electric waveTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1053 Accepted Submission(s): 354 Problem Description Ali was doing a physic experiment which requires him to observe an electric wave. He needs the height of each peak value and valley value for further study (a peak value means the value is strictly larger than its neighbors and a valley value means the value is strictly smaller than its neighbors). He did write these numbers down but he was too careless that he wrote them in a line without separations, such as ¡°712495¡± may represent ¡°7 12 4 9 5¡±. The only information he can remember was: 1. The data begins with a valley value 2. Each value is either a peak value or a valley value Now he wants to insert blanks to make the data valid. If multiple solutions exist, he will choose the one with more blanks. Input The input consists several testcases. The first line contains one integer N (1 <= N <= 100), the length of the data. The second line contains one string S, the data he recorded. S contains only digits. Output Print one integer, the maximum number of blanks he can insert. Sample Input
Sample Output
Hint The separated data may have leading zeros. Source | ||||||||||
|