CF137A.Postcards and photos
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Polycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the right and removes the objects consecutively. As Polycarpus doesn't want any mix-ups to happen, he will not carry in his hands objects of two different types. In other words, Polycarpus can't carry both postcards and photos simultaneously. Sometimes he goes to the closet and puts the objects there, thus leaving his hands free. Polycarpus must put all the postcards and photos to the closet. He cannot skip objects. What minimum number of times he should visit the closet if he cannot carry more than 5 items?
波利卡普斯将明信片和照片依次挂在墙上。他决定把这些物品收进衣柜,并在墙上挂上一位著名画家的画作。波利卡普斯的操作方式如下:他从左到右依次取下这些物品。由于波利卡普斯不希望发生任何混乱,他手中不能同时持有两种不同类型的物品。换言之,他不能同时拿着明信片和照片。有时他会前往衣柜,把手中的物品放进去,从而腾出双手。波利卡普斯必须将所有明信片和照片都收进衣柜,且不能跳过任何物品。如果他每次最多只能携带 5 件物品,那么他至少需要去衣柜多少次?
输入格式
The only line of the input data contains a non-empty string consisting of letters "С" and "P" whose length does not exceed 100 characters. If the i-th character in the string is the letter "С", that means that the i-th object (the numbering goes from the left to the right) on Polycarpus' wall is a postcard. And if the i-th character is the letter "P", than the i-th object on the wall is a photo.
输入数据仅有一行,包含一个非空字符串,该字符串由字母“С”和“P”组成,长度不超过 100 个字符。如果字符串中第 i 个字符是字母“С”,则表示 Polycarpus 墙上从左到右编号为 i 的物品是一张明信片;如果第 i 个字符是字母“P”,则墙上编号为 i 的物品是一张照片。
输出格式
Print the only number — the minimum number of times Polycarpus has to visit the closet.
输出唯一的数字——Polycarpus 需要访问衣柜的最少次数。
输入输出样例
输入#1
CPCPCPC
输出#1
7
输入#2
CCCCCCPPPPPP
输出#2
4
输入#3
CCCCCCPPCPPPPPPPPPP
输出#3
6
输入#4
CCCCCCCCCC
输出#4
2
说明/提示
In the first sample Polycarpus needs to take one item to the closet 7 times.
In the second sample Polycarpus can first take 3 postcards to the closet; then 3 more. He can take the 6 photos that are left in the similar way, going to the closet twice.
In the third sample Polycarpus can visit the closet twice, both times carrying 3 postcards. Then he can take there 2 photos at once, then one postcard and finally, he can carry the last 10 photos if he visits the closet twice.
In the fourth sample Polycarpus can visit the closet twice and take there all 10 postcards (5 items during each go).
在第一个样例中,Polycarpus 需要将一件物品送到壁橱中 7 次。
在第二个样例中,Polycarpus 可以先将 3 张明信片送到壁橱中,然后再送另外 3 张。剩下的 6 张照片也可以用类似的方式分两次送到壁橱中。
在第三个样例中,Polycarpus 可以两次前往壁橱,每次携带 3 张明信片。然后他可以一次性将 2 张照片送到壁橱中,接着再送 1 张明信片,最后,若他两次前往壁橱,则可将剩余的 10 张照片全部送完。
在第四个样例中,Polycarpus 可以两次前往壁橱,将全部 10 张明信片送完(每次运送 5 件物品)。
输入解题思路,AI测评打分。不知道怎么写?