304434: CF847E. Packmen
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Packmen
题意翻译
输入n, 接着给你一个长度为n的字符串。 *代表包装, P代表人, .代表为空, 人移动一单位距离需要花费一秒,人可以向左或者向右移动。人只要走到包装的位置,就会把包装吃掉,问你最少需要多少秒。所有的包装就被人全吃完题目描述
A game field is a strip of $ 1×n $ square cells. In some cells there are Packmen, in some cells — asterisks, other cells are empty. Packman can move to neighboring cell in $ 1 $ time unit. If there is an asterisk in the target cell then Packman eats it. Packman doesn't spend any time to eat an asterisk. In the initial moment of time all Packmen begin to move. Each Packman can change direction of its move unlimited number of times, but it is not allowed to go beyond the boundaries of the game field. Packmen do not interfere with the movement of other packmen; in one cell there can be any number of packmen moving in any directions. Your task is to determine minimum possible time after which Packmen can eat all the asterisks.输入输出格式
输入格式
The first line contains a single integer $ n $ ( $ 2<=n<=10^{5} $ ) — the length of the game field. The second line contains the description of the game field consisting of $ n $ symbols. If there is symbol '.' in position $ i $ — the cell $ i $ is empty. If there is symbol '\*' in position $ i $ — in the cell $ i $ contains an asterisk. If there is symbol 'P' in position $ i $ — Packman is in the cell $ i $ . It is guaranteed that on the game field there is at least one Packman and at least one asterisk.
输出格式
Print minimum possible time after which Packmen can eat all asterisks.
输入输出样例
输入样例 #1
7
*..P*P*
输出样例 #1
3
输入样例 #2
10
.**PP.*P.*
输出样例 #2
2