# CFR 795 J. Stepan's Series ( Ad hoc )

Problem - J - Codeforces

The first line contains two integers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ n) — the number of episodes in the series and the dissatisfaction which should be checked.
The second line contains the sequence which consists of n symbols "Y", "N" and "?". If the i-th symbol equals "Y", Stepan remembers that he has watched the episode number i. If the i-th symbol equals "N", Stepan remembers that he hasn't watched the epizode number i. If the i-th symbol equals "?", Stepan doesn't exactly remember if he has watched the episode number i or not.

O( N )

```package main

import "fmt"

func Max( x, y int ) int { // math.Max() は問題を起こすらしい。。。
if x > y {
return x
}
return y
}

func main() {
var N, K int
fmt.Scan( &N, &K )
var S string
fmt.Scan( &S )
ypfx := make( []int, N + 1, N + 1 ); // type, length, capacity
npfx := make( []int, N + 1, N + 1 );
qpfx := make( []int, N + 1, N + 1 );
for i := 0; i < N; i++ { // seems like go does not support ++i.....
ypfx[ i + 1 ] = ypfx[ i ];
npfx[ i + 1 ] = npfx[ i ];
qpfx[ i + 1 ] = qpfx[ i ];
if( S[ i ] == 'Y' ) {
ypfx[ i + 1 ]++;
} else if( S[ i ] == 'N' ) {
npfx[ i + 1 ]++;
} else {
qpfx[ i + 1 ]++;
}
}
original_max := 0;
for i := 0; i < N; i++ {
if( S[ i ] != 'N' ) { // syntax error: missing { after if clause えええええ
continue;
}
j := i;
for j < N && S[ j ] == 'N' { // while() はだめなんかい！！
j++;
}
original_max = Max( original_max, j - i );
i = j;
}
if( original_max > K ) {
fmt.Println( "NO" );
return;
}
for i := 0; i + K <= N; i++ { // i を左界とする長さ K の区間を調べる
if( ypfx[ i + K ] - ypfx[ i ] > 0 ) { // ええええ -> line: 34
continue;
}
if( i - 1 >= 0 && S[ i - 1 ] == 'N' ) {
continue;
}
if( i + K < N && S[ i + K ] == 'N' ) {
continue;
}
fmt.Println( "YES" );
return;
}
fmt.Println( "NO" );
}
```