QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 512 MB مجموع النقاط: 100

#4302. 顺子

الإحصائيات

广义扑克锦标赛即将开始!比赛使用一副特殊的牌,牌中包含从 $1$ 到 $n$ 的整数。每种数字在牌堆中都有无限多张。

广义扑克中只有一种牌型:顺子。顺子是指包含 $m$ 张连续整数的牌序列:$i, i + 1, \dots, i + m - 1$。扑克规则如下:每位玩家拥有 $s$ 张底牌,桌上有 $m$ 张公共牌。因此,每位玩家总共能看到 $s + m$ 张牌,并尝试从中选出 $m$ 张组成一个顺子。

你正在观看比赛,因此你只能看到公共牌。你想知道,对于某些可能的底牌,能够组成多少种不同的顺子。如果两个顺子的起始值 $i$ 不同,则它们是不同的。

输入格式

第一行包含三个整数 $n, m$ 和 $s$ ($1 \le n \le 10^9$; $1 \le s < m \le 10^5$),分别表示牌的最大数值、公共牌的数量以及底牌的数量。

第二行包含 $m$ 个整数,每个整数在 $1$ 到 $n$ 之间,表示公共牌的数值。

输出格式

输出玩家可能组成的顺子的不同数量。

样例

输入 1

10 5 2
7 1 3 5 6

输出 1

5

输入 2

11 6 2
5 5 5 5 5 5

输出 2

0

说明

第一个样例中可能的顺子起始值有:1, 2, 3, 4 和 5。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.