Problem Description
Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can replace any pair of consecutive moves RU or UR with a diagonal move (described as character D). After that, he can go on and do some other replacements, until there is no pair of consecutive moves RU or UR left.
Your problem is to print the minimum possible length of the sequence of moves after the replacements.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 100) — the length of the sequence. The second line contains the sequence co

博客介绍了Codeforces的一道题目,挑战者Mikhail在2D平面上只能向上或向右移动。他希望优化连续的RU或UR序列,用D表示对角线移动来缩短移动序列。输入是移动序列长度和序列本身,目标是找出替换后序列的最短长度。提供了示例和代码实现。
最低0.47元/天 解锁文章
930

被折叠的 条评论
为什么被折叠?



