#P10695. [SNCPC2024] 商路

[SNCPC2024] 商路

Problem Description

A circle is divided into KK equal parts by KK points, numbered clockwise as 1,2,,K1, 2, \cdots, K. Among them, points a1,a2,,ana_1, a_2, \cdots, a_n each have a market M1,M2,,MnM_1, M_2, \cdots, M_n built on them.

A trade route starting from market ii and aiming at market jj is a directed line segment MiMjM_i M_j (iji \neq j), and it must satisfy the following conditions:

  • Market jj must be the farthest market from market ii (if there are multiple farthest markets at the same distance, any one of them is allowed).
  • The trade route segment MiMjM_i M_j must not intersect or overlap with any other trade route segment at any place other than their starting points or ending points.

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

Input Format

The first line contains two integers K,nK, n (3K109,3nmin(K,105)3 \leq K \leq 10^9, 3\leq n \leq \min(K,10^5)), separated by spaces, meaning that nn markets are placed on the KK equally divided points on the circle.

The second line contains nn integers a1,a2,,ana_1, a_2, \cdots, a_n (1a1<a2<<an1<anK1\leq a_1 < a_2 < \cdots < a_{n-1} < a_n \leq K), which are the indices of the points where markets are built.

Output Format

Output one integer, the maximum number of trade routes that can exist.

10 5
1 2 5 6 8

2

3 3
1 2 3

3

Hint

For the first sample, two possible answers are shown in the figures below:

Translated by ChatGPT 5