P28102 [洛谷] [SNCPC2024] Trade Routes
提高-
题目描述

Problem Description

A circle is equally divided by $K$ points, which are numbered clockwise as $1, 2, \cdots, K$. Among these points, markets $M_1, M_2, \cdots, M_n$ are built at points $a_1, a_2, \cdots, a_n$ respectively.

A trade route starting from market $i$ and targeting market $j$ is a directed segment $M_i M_j$ ($i \neq j$) and must satisfy the following conditions:

  • Market $j$ must be the farthest market from market $i$ (if there are multiple markets at the same farthest distance, any one of them can be chosen).
  • The trade route segment $M_i M_j$ must not intersect or overlap with any other trade route segments except at the start or end points.

What is the maximum number of trade routes that can exist?

Input Format

The first line contains two integers $K, n$ ($3 \leq K \leq 10^9, 3 \leq n \leq \min(K, 10^5)$), separated by a space, indicating that there are $n$ markets distributed at $K$ equal division points of the circle.

The second line contains $n$ integers $a_1, a_2, \cdots, a_n$ ($1 \leq a_1 < a_2 < \cdots < a_{n-1} < a_n \leq K$), representing the numbers of the points where markets are built.

Output Format

Output a single integer representing the maximum number of trade routes that can exist.

Sample Input and Output

Sample Input #1

10 5
1 2 5 6 8

Sample Output #1

2

Sample Input #2

3 3
1 2 3

Sample Output #2

3

Notes

For the first sample, two possible solutions are shown in the following images:

Image 1

Image 2

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
10 5 1 2 5 6 8
样例输出
2