4390 : Same Color
- 제한시간
- 1000 ms
- 메모리제한
- 512 MB
- 해결횟수
- 2 회
- 시도횟수
- 12 회
문제
There are n distinct points with m colors on the line, where m ≤ n. Let S be the set of those points. We want to select a non-empty subset C ⊆ S that satisfies the following:

입력형식
Your program is to read from standard input. The input starts with a line containing two integers, m and n (1 ≤ m ≤ n ≤ 100,000), where m is the number of colors and n is the number of points. The points are numbered 1 to n from left to right on the line, and the colors are numbered 1 to m. The second line contains a sequence of sorted n integers in increasing manner, where the i-th number is the coordinate of the point i. The coordinates x of points satisfy 0 ≤ x ≤ 109 and are all distinct. The third line contains a sequence of n integers, where the i-th number is the color of the point i, which is between 1 and m.
출력형식
Your program is to write to standard output. Print exactly one line. The line should contain the minimum cardinality of a non-empty subset C of S to satisfy the above property.
입력 예복사하기 2 6 0 3 4 7 8 11 1 1 1 2 2 1 |
출력 예복사하기 3 |
입력 예복사하기 2 6 0 3 4 7 8 11 1 2 1 2 2 1 |
출력 예복사하기 5 |