300885: CF169A. Chores

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Chores

题意翻译

## 题目描述: 彼佳和瓦西亚是兄弟。今天对他们来说是个特殊的日子,因为他们的父母把他们独自留在家里,让他们做家务。每个杂务都有一个单一的参数——它的复杂度。第$i$个杂务的复杂度等于$h_{i}$ 由于彼佳年纪较大,他想要承担那些复杂的家务$(h_{i}>x)$,把较为简单的家务留给瓦西亚。$(h_{i}<=x)$。兄弟俩已经决定,彼佳做$a$个家务,瓦西亚做$b$个家务$(a+b=n)$。 有多少种方法可以让他们选择一个整数$x$,使得满足上述条件的情况下,彼佳正好做a个家务,瓦西亚正好做$b$个家务? ## 输入格式: 第一行输入三个整数$n,a,b(2<=n<=2000;a,b>=1;a+b=n)$,分别代表家务的总数,彼佳做的家务数量和瓦西亚做的家务数量。 第二行一个整数序列$h_{1},h_{2},……,h_{n}(1<=h_{i}<=10^9)$,代表各项杂务的复杂度。序列中的数字有可能相同。 输入的所有数字都用单个空格隔开。 ## 输出格式: 一行一个整数$x$,代表可行的方案数量。如果,没有可行的方案,输出0。 ## 说明: 在第一个样例中,$x$ 可能为3,4,5

题目描述

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}&gt;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?

输入输出格式

输入格式


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}<=10^{9} $ ), $ 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.

输出格式


Print the required number of ways to choose an integer value of $ x $ . If there are no such ways, print 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.

Input

题意翻译

## 题目描述: 彼佳和瓦西亚是兄弟。今天对他们来说是个特殊的日子,因为他们的父母把他们独自留在家里,让他们做家务。每个杂务都有一个单一的参数——它的复杂度。第$i$个杂务的复杂度等于$h_{i}$ 由于彼佳年纪较大,他想要承担那些复杂的家务$(h_{i}>x)$,把较为简单的家务留给瓦西亚。$(h_{i}<=x)$。兄弟俩已经决定,彼佳做$a$个家务,瓦西亚做$b$个家务$(a+b=n)$。 有多少种方法可以让他们选择一个整数$x$,使得满足上述条件的情况下,彼佳正好做a个家务,瓦西亚正好做$b$个家务? ## 输入格式: 第一行输入三个整数$n,a,b(2<=n<=2000;a,b>=1;a+b=n)$,分别代表家务的总数,彼佳做的家务数量和瓦西亚做的家务数量。 第二行一个整数序列$h_{1},h_{2},……,h_{n}(1<=h_{i}<=10^9)$,代表各项杂务的复杂度。序列中的数字有可能相同。 输入的所有数字都用单个空格隔开。 ## 输出格式: 一行一个整数$x$,代表可行的方案数量。如果,没有可行的方案,输出0。 ## 说明: 在第一个样例中,$x$ 可能为3,4,5

加入题单

算法标签: