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

23567번 - Double Rainbow 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB119352135842.619%

문제

Let $P$ be a set of $n$ points on the $x$-axis and each of the points is colored with one of the colors 1,ドル 2, \dots , k$. For each color i of the k colors, there is at least one point in $P$ which is colored with $i$. For a set $P'$ of consecutive points from $P,ドル if both $P'$ and $P \backslash P'$ contain at least one point of each color, then we say that $P'$ makes a double rainbow. See the below figure as an example. The set P consists of ten points and each of the points is colored by one of the colors 1ドル,ドル 2ドル,ドル 3ドル,ドル and 4ドル$. The set $P'$ of the five consecutive points contained in the rectangle makes a double rainbow.

Given a set $P$ of points and the number $k$ of colors as input, write a program that computes and prints out the minimum size of $P'$ that makes a double rainbow.

입력

Your program is to read from standard input. The input starts with a line containing two integers $n$ and $k$ (1ドル ≤ k ≤ n ≤ 10,000$), where $n$ is the number of the points in $P$ and $k$ is the number of the colors. Each of the following $n$ lines consists of an integer from 1ドル$ to $k,ドル inclusively, and the $i$-th line corresponds to the color of the $i$-th point of $P$ from the left.

출력

Your program is to write to standard output. Print exactly one line. The line should contain the minimum size of $P'$ that makes a double rainbow. If there is no such $P',ドル print 0.

제한

예제 입력 1

10 4
1
2
3
1
1
4
2
4
3
3

예제 출력 1

5

예제 입력 2

6 3
1
1
2
2
3
3

예제 출력 2

0

힌트

출처

ICPC > Regionals > Asia Pacific > Korea > Asia Regional - Seoul 2021 B번

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

출처

대학교 대회

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

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