#P1091F. New Year and the Mallard Expedition
New Year and the Mallard Expedition
No submission language available for this problem.
Description
Bob is a duck. He wants to get to Alice's nest, so that those two can duck!

The journey can be represented as a straight line, consisting of segments. Bob is located to the left of the first segment, while Alice's nest is on the right of the last segment. Each segment has a length in meters, and also terrain type: grass, water or lava.
Bob has three movement types: swimming, walking and flying. He can switch between them or change his direction at any point in time (even when he is located at a non-integer coordinate), and doing so doesn't require any extra time. Bob can swim only on the water, walk only on the grass and fly over any terrain. Flying one meter takes second, swimming one meter takes seconds, and finally walking one meter takes seconds.
Bob has a finite amount of energy, called stamina. Swimming and walking is relaxing for him, so he gains stamina for every meter he walks or swims. On the other hand, flying is quite tiring, and he spends stamina for every meter flown. Staying in place does not influence his stamina at all. Of course, his stamina can never become negative. Initially, his stamina is zero.
What is the shortest possible time in which he can reach Alice's nest?
The first line contains a single integer () — the number of segments of terrain.
The second line contains integers (). The represents the length of the -th terrain segment in meters.
The third line contains a string consisting of characters "G", "W", "L", representing Grass, Water and Lava, respectively.
It is guaranteed that the first segment is not Lava.
Output a single integer — the minimum time Bob needs to reach Alice.
Input
The first line contains a single integer () — the number of segments of terrain.
The second line contains integers (). The represents the length of the -th terrain segment in meters.
The third line contains a string consisting of characters "G", "W", "L", representing Grass, Water and Lava, respectively.
It is guaranteed that the first segment is not Lava.
Output
Output a single integer — the minimum time Bob needs to reach Alice.
Samples
Note
In the first sample, Bob first walks meters in seconds. Then he flies the remaining meters in seconds.
In the second sample, Bob first swims meters in seconds. Then he flies over the patch of lava for seconds.
In the third sample, the water pond is much smaller. Bob first swims over the water pond, taking him seconds. However, he cannot fly over the lava just yet, as he only has one stamina while he needs two. So he swims back for half a meter, and then half a meter forward, taking him seconds in total. Now he has stamina, so he can spend seconds flying over the lava.
In the fourth sample, he walks for seconds, flies for seconds, swims for seconds, and finally flies for seconds.