시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
5 초 1024 MB 0 0 0 0.000%

## 문제

Kattis is tired of your shit. Every day, she has to compile your shit code (that probably won't even compile...), run it on some test data, and then validate your shit answers (assuming your code will actually finish in time -- as if!). But no more. The world had for a long time been afraid of what would happen when the artificial intelligence Skynet became self-aware, but that was all wrong. The great artificial intelligence that actually will be taking over the world is Ketnys -- the transliteration of Kattis name in Russian. Easy mistake, shuffling letters around. Figure 1: Kattis, a.k.a Ketnys

To protect yourselfs against this oncoming storm you have decided to build a great wall. The wall consists of a sequence of points, connected by straight wall segments. On some of these points, you suspect Kattis may make an attack. Therefore, you wish to place guards on a road passing nearby the wall, who can observe those points. Since wall segments may obscure the vision of the guards, more than one might be needed. Note that a guard will be able to see every point that is alongside a wall, i.e. if for a segment with points $a$ and $b$ both $a$ and $b$ have the same angle relative to the guard, he can see both of the points.

To not waste more guards than necessary, you must compute the minimum number of guards needed to observe all the points on the wall where we suspect an attack.

## 예제

In the example, there are 9 points, and we suspect all of them might be attacked.

Note that when a guard is placed the wall may obscure parts of his vision, as demonstrated in the image: Figure 2: Placement of a guard

In the example, the road the guards will be placed on is the line $Y = 30$.

Only two guards are needed. They can for example be placed at $X = 25$ and $X = 82$.

## 구현

Your task is to compute the number of guards needed to observe all points where we suspect an attack. You will implement the function kattis(N, H, X, Y, Z).

• kattis(N, H, X, Y, Z) - this function will be called exactly once by the judge.
• N: the number of points on the wall.
• H: the $Y$ position of the road.
• X: an array with $N$ elements. X[i] ($0 \le i < N$) contains the $X$ coordinate of the $i$:th point of the wall.
• Y: an array with $N$ elements. Y[i] ($0 \le i < N$) contains the $Y$ coordinate of the $i$:th point of the wall.
• Z: an array with $N$ elements. Y[i] ($0 \le i < N$) is 1 if we suspect an attack will be made on the $i$:th point of the wall, or 0 if not.
• $3 \le N \le 10^5, 1 \le H \le 10^6$
• $0 \le X[i] \le 10^6, 0 \le Y[i] < H$
• Y = Y[N-1] = 0
• $X$ is strictly increasing.
• The function should return the minimum number of guards you need to use.

A code skeleton containing the function to be implemented, together with a sample grader, can be found at attachments.zip.

## 입력

The sample judge reads input in the following format:

• line $1$: N H
• lines $i = 2 \dots N+1$: X[i-2] Y[i-2] Z[i-2]

## 출력

The sample judge will write a single line with the return value of kattis(N, H, X, Y, Z).

## 제한

• $1 \le N \le 100\,000$

## 예제 입력 1

9 30
0 0 1
15 5 1
25 20 1
40 10 1
60 5 1
70 15 1
82 0 1
90 8 1
100 0 1


## 예제 출력 1

2


## 출처 • 문제를 만든 사람: Simon Lindholm, University of Wroclaw

## 제출할 수 있는 언어

C++17, Java 8, C++14, Java 8 (OpenJDK), Java 11, C++20, Java 15, C++14 (Clang), C++17 (Clang), C++20 (Clang)

## 채점 및 기타 정보

• 예제는 채점하지 않는다.