CF169A.Chores

普及/提高-

通过率:0%

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 nn chores. Each chore is characterized by a single parameter — its complexity. The complexity of the ii -th chore equals hih_{i} .

As Petya is older, he wants to take the chores with complexity larger than some value xx ( h_{i}>x ) to leave to Vasya the chores with complexity less than or equal to xx ( hi<=xh_{i}<=x ). The brothers have already decided that Petya will do exactly aa chores and Vasya will do exactly bb chores ( a+b=na+b=n ).

In how many ways can they choose an integer xx so that Petya got exactly aa chores and Vasya got exactly bb chores?

输入格式

The first input line contains three integers n,an,a and bb ( 2<=n<=20002<=n<=2000 ; a,b>=1a,b>=1 ; a+b=na+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 h1,h2,...,hnh_{1},h_{2},...,h_{n} ( 1<=hi<=1091<=h_{i}<=10^{9} ), hih_{i} is the complexity of the ii -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 xx . 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 xx are 3, 4 or 5.

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

首页