CF169A.Chores

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Petya and Vasya are brothers. Today is a special day for them as their parents left them home alone and commissioned them to do n chores. Each chore is characterized by a single parameter — its complexity. The complexity of the i-th chore equals h__i.

As Petya is older, he wants to take the chores with complexity larger than some value x (h__i > x) to leave to Vasya the chores with complexity less than or equal to x (h__i ≤ x). The brothers have already decided that Petya will do exactly a chores and Vasya will do exactly b chores (a + b = n).

In how many ways can they choose an integer x so that Petya got exactly a chores and Vasya got exactly b chores?

佩佳和瓦夏是兄弟。今天对他们来说是个特殊的日子,因为父母将他们单独留在家中,并委托他们完成 nn 项家务。每项家务仅由一个参数刻画——其难度。第 ii 项家务的难度为 hih_i。

由于佩佳年龄较大,他希望承担难度大于某个值 xx 的家务(即 hi>xh_i > x),而将难度小于等于 xx 的家务(即 hi≤xh_i \leq x)留给瓦夏。兄弟俩已经约定:佩佳恰好完成 aa 项家务,瓦夏恰好完成 bb 项家务(满足 a+b=na + b = n)。

有多少个整数 xx 的取值方式,使得佩佳恰好分到 aa 项家务、瓦夏恰好分到 bb 项家务?

输入格式

The first input line contains three integers n, a and b (2 ≤ n ≤ 2000; a, b ≥ 1; a + b = n) — the total number of chores, the number of Petya's chores and the number of Vasya's chores.

The next line contains a sequence of integers _h_1, _h_2, ..., h__n (1 ≤ h__i ≤ 109), h__i is the complexity of the i-th chore. The numbers in the given sequence are not necessarily different.

All numbers on the lines are separated by single spaces.

第一行输入包含三个整数 nn、aa 和 bb(2≤n≤20002 \leq n \leq 2000;a,b≥1a, b \geq 1;a+b=na + b = n)—— 分别表示家务任务的总数、Petya 需要完成的任务数以及 Vasya 需要完成的任务数。

第二行包含一个整数序列 h1,h2,…,hnh_1, h_2, \dots, h_n(1≤hi≤1091 \leq h_i \leq 10^9),其中 hih_i 表示第 ii 项任务的难度。给定序列中的数字不一定互不相同。

每行中的所有数字均以单个空格分隔。

输出格式

Print the required number of ways to choose an integer value of x. If there are no such ways, print 0.

输出选择整数 xx 的满足条件的方案数。若不存在满足条件的方案,则输出 0。

输入输出样例

  • 输入#1

    5 2 3
    6 2 3 100 1

    输出#1

    3
  • 输入#2

    7 3 4
    1 1 9 1 1 1 1

    输出#2

    0

说明/提示

In the first sample the possible values of x are 3, 4 or 5.

In the second sample it is impossible to find such x, that Petya got 3 chores and Vasya got 4.

在第一个样例中,xx 的可能取值为 33、44 或 55。

在第二个样例中,不存在满足条件的 xx,使得佩佳完成了 33 项家务,而瓦夏完成了 44 项家务。

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

首页