AtCoder Regular Contest 179
A
Partition
AtCoder
⌀ 504
原题
←B →
翻译中…

Problem Statement

翻译中…

You are given integers $N$ and $K$.

翻译中…

The cumulative sums of an integer sequence $X=(X_1,X_2,\dots ,X_N)$ of length $N$ is defined as a sequence $Y=(Y_0,Y_1,\dots ,Y_N)$ of length $N+1$ as follows:

翻译中…
  • $Y_0=0$
  • $Y_i=\displaystyle\sum_{j=1}^{i}X_j\ (i=1,2,\dots ,N)$
翻译中…

An integer sequence $X=(X_1,X_2,\dots ,X_N)$ of length $N$ is called a good sequence if and only if it satisfies the following condition:

翻译中…
  • Any value in the cumulative sums of $X$ that is less than $K$ appears before any value that is not less than $K$.
  • Formally, for the cumulative sums $Y$ of $X$, for any pair of integers $(i,j)$ such that $0 \le i,j \le N$, if $(Y_i < K$ and $Y_j \ge K)$, then $i < j$.
翻译中…

You are given an integer sequence $A=(A_1,A_2,\dots ,A_N)$ of length $N$. Determine whether the elements of $A$ can be rearranged to a good sequence. If so, print one such rearrangement.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 2 \times 10^5$
  • $-10^9 \leq K \leq 10^9$
  • $-10^9 \leq A_i \leq 10^9$
  • All input values are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N K
A_1 A_2 \cdots A_N

翻译中…

Output

翻译中…

If the elements of $A$ can be rearranged to a good sequence, print the rearranged sequence $(A^{\prime}_1,A^{\prime}_2,\dots ,A^{\prime}_N)$ in the following format:

翻译中…

Yes
A^{\prime}_1 A^{\prime}_2 \cdots A^{\prime}_N

翻译中…

If there are multiple valid rearrangements, any of them is considered correct.

翻译中…

If a good sequence cannot be obtained, print No.

翻译中…

样例

Input #1
4 1
-1 2 -3 4
Output #1
Yes
-3 -1 2 4
If you rearrange $A$ to $(-3,-1,2,4)$, the cumulative sums $Y$ in question will be $(0,-3,-4,-2,2)$. In this $Y$, any value less than $1$ appears before any value not less than $1$.
Input #2
4 -1
1 -2 3 -4
Output #2
No
Input #3
10 1000000000
-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
Output #3
Yes
-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
题目信息
题号
arc179_a
时间限制
2 s
内存限制
1024 MB

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