304716: CF899E. Segments Removal
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Segments Removal
题意翻译
每次删除长度最长的最左面的一段连续的数字区间,求删除次数题目描述
Vasya has an array of integers of length $ n $ . Vasya performs the following operations on the array: on each step he finds the longest segment of consecutive equal integers (the leftmost, if there are several such segments) and removes it. For example, if Vasya's array is $ [13,13,7,7,7,2,2,2] $ , then after one operation it becomes $ [13,13,2,2,2] $ . Compute the number of operations Vasya should make until the array becomes empty, i.e. Vasya removes all elements from it.输入输出格式
输入格式
The first line contains a single integer $ n $ ( $ 1<=n<=200000 $ ) — the length of the array. The second line contains a sequence $ a_{1},a_{2},...,a_{n} $ ( $ 1<=a_{i}<=10^{9} $ ) — Vasya's array.
输出格式
Print the number of operations Vasya should make to remove all elements from the array.
输入输出样例
输入样例 #1
4
2 5 5 2
输出样例 #1
2
输入样例 #2
5
6 3 4 1 5
输出样例 #2
5
输入样例 #3
8
4 4 4 2 2 100 100 100
输出样例 #3
3
输入样例 #4
6
10 10 50 10 50 50
输出样例 #4
4