It's Mooin' Time
시간 제한3초메모리 제한2048 MB
L이 3 이하일 때, M과 그 뒤 L-1개의 O로 이루어진 부분 문자열을 k개 이상 포함하도록 문자열을 고치는 최소 비용을 모든 k에 대해 구한다.
문제
Bessie has a string of length () consisting solely of the characters M and O. For each position of the string, there is a cost to change the character at that position to the other character ().
Bessie thinks the string will look better if it contains more moos of length (). A moo of length is an M followed by Os.
For each positive integer from to inclusive, compute the minimum cost to change the string to contain at least substrings equal to a moo of length .
입력
The first line contains and .
The next line contains Bessie's length- string, consisting solely of Ms and Os.
The next line contains space-separated integers .
출력
Output lines, the answer for each in increasing order.