CF985E.Pencils and Boxes

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome world, where everything is of the same color and only saturation differs. This pack can be represented as a sequence a1,a2,...,ana_{1},a_{2},...,a_{n} of nn integer numbers — saturation of the color of each pencil. Now Mishka wants to put all the mess in the pack in order. He has an infinite number of empty boxes to do this. He would like to fill some boxes in such a way that:

  • Each pencil belongs to exactly one box;
  • Each non-empty box has at least kk pencils in it;
  • If pencils ii and jj belong to the same box, then aiaj<=d|a_{i}-a_{j}|<=d , where x|x| means absolute value of xx . Note that the opposite is optional, there can be pencils ii and jj such that aiaj<=d|a_{i}-a_{j}|<=d and they belong to different boxes.

Help Mishka to determine if it's possible to distribute all the pencils into boxes. Print "YES" if there exists such a distribution. Otherwise print "NO".

输入格式

The first line contains three integer numbers nn , kk and dd ( 1<=k<=n<=51051<=k<=n<=5·10^{5} , 0<=d<=1090<=d<=10^{9} ) — the number of pencils, minimal size of any non-empty box and maximal difference in saturation between any pair of pencils in the same box, respectively.

The second line contains nn integer numbers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 1<=ai<=1091<=a_{i}<=10^{9} ) — saturation of color of each pencil.

输出格式

Print "YES" if it's possible to distribute all the pencils into boxes and satisfy all the conditions. Otherwise print "NO".

输入输出样例

  • 输入#1

    6 3 10
    7 2 7 7 4 2
    

    输出#1

    YES
    
  • 输入#2

    6 2 3
    4 5 3 13 4 10
    

    输出#2

    YES
    
  • 输入#3

    3 2 5
    10 16 22
    

    输出#3

    NO
    

说明/提示

In the first example it is possible to distribute pencils into 22 boxes with 33 pencils in each with any distribution. And you also can put all the pencils into the same box, difference of any pair in it won't exceed 1010 .

In the second example you can split pencils of saturations [4,5,3,4][4,5,3,4] into 22 boxes of size 22 and put the remaining ones into another box.

首页