Codeforces Round 148 (Div. 1)
B
Boring Partition
Codeforces
1800
原题
← AC →
翻译中…

This problem is the most boring one you've ever seen.

翻译中…

Given a sequence of integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ and a non-negative integer $*h*$, our goal is to partition the sequence into two subsequences (not necessarily consist of continuous elements). Each element of the original sequence should be contained in exactly one of the result subsequences. Note, that one of the result subsequences can be empty.

翻译中…

Let's define function $*f*(*a*_{*i*}, *a*_{*j*})$ on pairs of distinct elements (that is $*i* ≠ *j*$) in the original sequence. If $*a*_{*i*}$ and $*a*_{*j*}$ are in the same subsequence in the current partition then $*f*(*a*_{*i*}, *a*_{*j*}) = *a*_{*i*} + *a*_{*j*}$ otherwise $*f*(*a*_{*i*}, *a*_{*j*}) = *a*_{*i*} + *a*_{*j*} + *h*$.

翻译中…

Consider all possible values of the function $*f*$ for some partition. We'll call the goodness of this partiotion the difference between the maximum value of function $*f*$ and the minimum value of function $*f*$.

翻译中…

Your task is to find a partition of the given sequence $*a*$ that have the minimal possible goodness among all possible partitions.

翻译中…

Input

翻译中…

The first line of input contains integers $*n*$ and $*h*$ $(2 ≤ *n* ≤ 10^{5}, 0 ≤ *h* ≤ 10^{8})$. In the second line there is a list of $*n*$ space-separated integers representing $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ $(0 ≤ *a*_{*i*} ≤ 10^{8})$.

翻译中…

Output

翻译中…

The first line of output should contain the required minimum goodness.

翻译中…

The second line describes the optimal partition. You should print $*n*$ whitespace-separated integers in the second line. The $*i*$-th integer is $1$ if $*a*_{*i*}$ is in the first subsequence otherwise it should be $2$.

翻译中…

If there are several possible correct answers you are allowed to print any of them.

翻译中…

Note

翻译中…

In the first sample the values of $*f*$ are as follows: $*f*(1, 2) = 1 + 2 + 2 = 5$, $*f*(1, 3) = 1 + 3 + 2 = 6$ and $*f*(2, 3) = 2 + 3 = 5$. So the difference between maximum and minimum values of $*f*$ is $1$.

翻译中…

In the second sample the value of $*h*$ is large, so it's better for one of the sub-sequences to be empty.

翻译中…

样例

Input #1
3 2
1 2 3
Output #1
1
1 2 2
InputCopy OutputCopy
Input #2
5 10
0 1 0 2 1
Output #2
3
2 2 2 2 2
InputCopy OutputCopy
题目信息
题号
238B
时间限制
2 s
内存限制
256 MB
标签
构造

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。