問題一覧 > 通常問題

No.2486 Don't come next to me

レベル : / AI推定難易度 : 1900 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 92
作問者 : takumaiq / テスター : ytqm3 highlighter
お気に入りにしたユーザー ProblemId : 10169 / 自分の提出
問題文最終更新日: 2023-09-29 22:50:08
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 406 技術室奥プログラミングコンテスト#7 Day2 (順位表) の他の問題:

Problem Statement

$N$ seats are arranged in a horizontal row.
The seats are numbered $1,2, ... ,N$ from the left. Currently, $M$ people are sitting at $A_1, A_2 ,..., A_M$ respectively.
From now on, $N-M$ people will enter the room one at a time. Each person chooses and sits in one of the seats that maximize the distance to the nearest person at that time.
Find the number of seats in which the last person to sit could possibly sit.

Input

$N$ $M$
$A_1$ $A_2$ $\ldots$ $A_M$
  • $1 \leq N \leq 10^{18}$
  • $2 \leq M \leq 2\times 10^5$
  • $M< N$ (corrected at 21:23)
  • $A_1=1,A_M=N$
  • $A_i < A_{i+1}$
  • All inputs are integers

Output

Print a newline at the end.

Sample

Sample 1
Input
7 3
1 5 7
Output
3

One possible seating order of the $N-M=7-3=4$ people is as follows.
The $1$st person sits in seat $3$.
The $2$nd person sits in seat $6$.
The $3$rd person sits in seat $2$.
The $4$th person sits in seat $4$.
Thus, seat $4$ may be taken by the last person to sit.
Similarly, seats $2,6$ also satisfy the condition.
Therefore, the value to output is $3$.

Sample 2
Input
12 5
1 4 5 7 12
Output
7

The empty seats are $2,3,6,8,9,10,11$, and all of these seats satisfy the condition.

Sample 3
Input
75 18
1 2 8 15 18 19 22 23 25 27 33 38 53 58 60 64 73 75
Output
54

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。