Logo
(追記) (追記ここまで)

8298번 - Coins 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB5101128525.298%

문제

Joe claims that he has telekinetic abilities. This statement has shocked Stan, who is a confirmed rationalist, and he immediately wanted Joe to prove it.

Joe decided to toss a coin to show what he is capable of. He says that he can do it in such a way, that there will be exactly k times more heads than tails. Stan has written down the results for all tosses and now he wants to find the longest sequence of consecutive tosses, in which heads are exactly k times more common than tails.

입력

The first line of the standard input contains two integers n and k (3 ≤ n ≤ 1 000 000, 2 ≤ kn - 1). The first is the number of tosses made by Joe, whereas the meaning of the second number has already been described in the task statement. The second line contains a sequence of n characters describing the outcomes of consecutive tosses. It consists of letters O and R denoting heads and tails respectively.

출력

Your program should output one integer to the first and only line of the standard output equal to the length of the longest sequence of consecutive tosses, in which there are exactly k times more heads than tails. If such sequence does not exist, your program should output 0.

제한

예제 입력 1

15 3
RORROOROOROOORO

예제 출력 1

8

힌트

The series from fifth to twelfth as well as from sixth to thirteenth toss contain exactly 6 heads and 2 tails, i.e., three times more heads than tails. There does not exist a longer sequence with this property.

출처

Contest > Algorithmic Engagements > PA 2010 2-2번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /