Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

2023-02-18,,,,

Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

题目连接:

http://codeforces.com/contest/985/problem/E

Description

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, ..., an of n 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 k pencils in it;
If pencils i and j belong to the same box, then |ai - aj| ≤ d, where |x| means absolute value of x. Note that the opposite is optional, there can be pencils i and j such that |ai - aj| ≤ 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".

Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes的相关教程结束。

《Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes.doc》

下载本文的Word格式文档,以方便收藏与打印。