折线AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)There are $N$ points on the $xy$-plane, numbered $1,2,\ldots,N$. The coordinates of point $i$ are $(i,A_i)$.
在 $xy$ 平面上有 $N$ 个点,编号为 $1,2,\ldots,N$。点 $i$ 的坐标为 $(i,A_i)$。AI (CI翻译)
For $i=1,2,\ldots,N-1$, connect point $i$ and point $i+1$ with a line segment to form one polyline.
对于 $i=1,2,\ldots,N-1$,用一条线段连接点 $i$ 和点 $i+1$,形成一条折线。AI (CI翻译)
Find the number of points on this polyline (including its endpoints) whose $y$-coordinate is $K$.
求这条折线上(包括端点)$y$ 坐标为 $K$ 的点的个数。AI (CI翻译)
Here, the constraints guarantee that the number of points satisfying the condition is finite.
约束条件保证满足条件的点的个数是有限的。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$2 \le N \le 100$$1 \le A_i \le 100$$(1 \le i \le N)$$A_i \ne A_{i+1}$$(1 \le i < N)$$1 \le K \le 100$- All input values are integers.
$2 \le N \le 100$$1 \le A_i \le 100$$(1 \le i \le N)$$A_i \ne A_{i+1}$$(1 \le i < N)$$1 \le K \le 100$- 所有输入值均为整数。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入通过标准输入以如下格式给出:AI (CI翻译)
N K
A_1 A_2 \ldots A_N
N K
A_1 A_2 \ldots A_NAI (CI翻译)
Output
输出格式
AI (CI翻译)Print the number of points on the polyline whose $y$-coordinate is $K$.
输出折线上 $y$ 坐标为 $K$ 的点的个数。AI (CI翻译)
样例
5 3
1 3 1 5 1
3
3 3
3 1 3
2
2 100
1 2
0
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。