Codeforces Round 345 (Div. 1)
B
Image Preview
Codeforces
1900
原题
← AC →
翻译中…

Vasya's telephone contains $*n*$ photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo $*n*$. Similarly, by swiping right from the last photo you reach photo $1$. It takes $*a*$ seconds to swipe from photo to adjacent.

翻译中…

For each photo it is known which orientation is intended for it — horizontal or vertical. Phone is in the vertical orientation and can't be rotated. It takes $*b*$ second to change orientation of the photo.

翻译中…

Vasya has $*T*$ seconds to watch photos. He want to watch as many photos as possible. If Vasya opens the photo for the first time, he spends $1$ second to notice all details in it. If photo is in the wrong orientation, he spends $*b*$ seconds on rotating it before watching it. If Vasya has already opened the photo, he just skips it (so he doesn't spend any time for watching it or for changing its orientation). It is not allowed to skip unseen photos.

翻译中…

Help Vasya find the maximum number of photos he is able to watch during $*T*$ seconds.

翻译中…

Input

翻译中…

The first line of the input contains 4 integers $*n*, *a*, *b*, *T*$ ($1 ≤ *n* ≤ 5·10^{5}$, $1 ≤ *a*, *b* ≤ 1000$, $1 ≤ *T* ≤ 10^{9}$) — the number of photos, time to move from a photo to adjacent, time to change orientation of a photo and time Vasya can spend for watching photo.

翻译中…

Second line of the input contains a string of length $*n*$ containing symbols 'w' and 'h'.

翻译中…

If the $*i*$-th position of a string contains 'w', then the photo $*i*$ should be seen in the horizontal orientation.

翻译中…

If the $*i*$-th position of a string contains 'h', then the photo $*i*$ should be seen in vertical orientation.

翻译中…

Output

翻译中…

Output the only integer, the maximum number of photos Vasya is able to watch during those $*T*$ seconds.

翻译中…

Note

翻译中…

In the first sample test you can rotate the first photo (3 seconds), watch the first photo (1 seconds), move left (2 second), rotate fourth photo (3 seconds), watch fourth photo (1 second). The whole process takes exactly 10 seconds.

翻译中…

Note that in the last sample test the time is not enough even to watch the first photo, also you can't skip it.

翻译中…

样例

Input #1
4 2 3 10
wwhw
Output #1
2
InputCopy OutputCopy
Input #2
5 2 4 13
hhwhh
Output #2
4
InputCopy OutputCopy
Input #3
5 2 4 1000
hhwhh
Output #3
5
InputCopy OutputCopy
Input #4
3 1 100 10
whw
Output #4
0
InputCopy OutputCopy
题目信息
题号
650B
时间限制
1 s
内存限制
256 MB
标签
二分
暴力
动态规划
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。