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

19829번 - The Pleasant Walk 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB27616012856.889%

문제

There are $n$ houses along the road where Anya lives, each one is painted in one of $k$ possible colors.

Anya likes walking along this road, but she doesn't like when two adjacent houses at the road have the same color. She wants to select a long segment of the road such that no two adjacent houses have the same color.

Help Anya find the longest segment with this property.

입력

The first line contains two integers $n$ and $k$ --- the number of houses and the number of colors (1ドル \le n \le 100,000円,ドル 1ドル \le k \le 100,000円$).

The next line contains $n$ integers $a_1, a_2, \ldots, a_n$ --- the colors of the houses along the road (1ドル \le a_i \le k$).

출력

Output a single integer --- the maximum number of houses on the road segment having no two adjacent houses of the same color.

제한

예제 입력 1

8 3
1 2 3 3 2 1 2 2

예제 출력 1

4

힌트

In the example, the longest segment without neighboring houses of the same color is from the house 4 to the house 7. The colors of the houses are $[3, 2, 1, 2]$ and its length is 4 houses.

출처

Olympiad > Russian Olympiad in Informatics > Russia Team High School Programming Contest > Russia Team High School Programming Contest 2018 M번

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

출처

대학교 대회

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

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