CF1539C.Stable Groups

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn students numerated from 11 to nn. The level of the ii-th student is aia_i. You need to split the students into stable groups. A group of students is called stable, if in the sorted array of their levels no two neighboring elements differ by more than xx.

For example, if x=4x = 4, then the group with levels [1,10,8,4,4][1, 10, 8, 4, 4] is stable (because 4−1≤x4 - 1 \le x, 4−4≤x4 - 4 \le x, 8−4≤x8 - 4 \le x, 10−8≤x10 - 8 \le x), while the group with levels [2,10,10,7][2, 10, 10, 7] is not stable (7−2=5>x7 - 2 = 5 \gt x).

Apart from the nn given students, teachers can invite at most kk additional students with arbitrary levels (at teachers' choice). Find the minimum number of stable groups teachers can form from all students (including the newly invited).

For example, if there are two students with levels 11 and 55; x=2x = 2; and k≥1k \ge 1, then you can invite a new student with level 33 and put all the students in one stable group.

有 nn 名学生,编号从 11 到 nn。第 ii 名学生的水平为 aia_i。你需要将这些学生划分为若干稳定组。一个学生组被称为稳定的,当且仅当将其水平按升序排列后,任意两个相邻元素之差不超过 xx。

例如,若 x=4x = 4,则水平为 [1,10,8,4,4][1, 10, 8, 4, 4] 的组是稳定的(因为 4−1≤x4 - 1 \le x,4−4≤x4 - 4 \le x,8−4≤x8 - 4 \le x,10−8≤x10 - 8 \le x),而水平为 [2,10,10,7][2, 10, 10, 7] 的组则不稳定(因为 7−2=5>x7 - 2 = 5 > x)。

除给定的 nn 名学生外,教师最多还可额外邀请 kk 名学生,其水平可由教师任意指定。求在所有学生(包括新邀请的学生)中所能形成的稳定组的最少数量。

例如,若已有两名学生,其水平分别为 11 和 55;x=2x = 2;且 k≥1k \ge 1,则你可以邀请一名水平为 33 的新学生,并将所有学生放入一个稳定组中。

输入格式

The first line contains three integers nn, kk, xx (1≤n≤200 0001 \le n \le 200\,000, 0≤k≤10180 \le k \le 10^{18}, 1≤x≤10181 \le x \le 10^{18}) — the initial number of students, the number of students you can additionally invite, and the maximum allowed level difference.

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤10181 \le a_i \le 10^{18}) — the students levels.

第一行包含三个整数 nn、kk、xx(1≤n≤200 0001 \le n \le 200\,000,0≤k≤10180 \le k \le 10^{18},1≤x≤10181 \le x \le 10^{18})—— 分别表示初始学生人数、可额外邀请的学生人数,以及允许的最大等级差。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤10181 \le a_i \le 10^{18})—— 表示各学生的等级。

输出格式

In the only line print a single integer: the minimum number of stable groups you can split the students into.

在唯一的一行中输出一个整数:将学生划分成的稳定组的最少数量。

输入输出样例

  • 输入#1

    8 2 3
    1 1 5 8 12 13 20 22

    输出#1

    2
  • 输入#2

    13 0 37
    20 20 80 70 70 70 420 5 1 5 1 60 90

    输出#2

    3

说明/提示

In the first example you can invite two students with levels 22 and 1111. Then you can split the students into two stable groups:

  1. [1,1,2,5,8,11,12,13][1, 1, 2, 5, 8, 11, 12, 13],
  2. [20,22][20, 22].

In the second example you are not allowed to invite new students, so you need 33 groups:

  1. [1,1,5,5,20,20][1, 1, 5, 5, 20, 20]
  2. [60,70,70,70,80,90][60, 70, 70, 70, 80, 90]
  3. [420][420]

在第一个例子中,你可以邀请两名水平分别为 22 和 1111 的学生。然后你可以将这些学生划分为两个稳定组:

  1. [1,1,2,5,8,11,12,13][1, 1, 2, 5, 8, 11, 12, 13],
  2. [20,22][20, 22]。

在第二个例子中,你不被允许邀请新学生,因此你需要 33 个组:

  1. [1,1,5,5,20,20][1, 1, 5, 5, 20, 20]
  2. [60,70,70,70,80,90][60, 70, 70, 70, 80, 90]
  3. [420][420]

输入解题思路,AI测评打分。不知道怎么写?

首页