AtCoder Regular Contest 149
D
Simultaneous Sugoroku
AtCoder
⌀ 2991
原题
← CE →
翻译中…

Problem Statement

翻译中…

There are $N$ pieces placed at integer coordinates on a number line. The coordinate of the $i$-th piece is $X_i$.

翻译中…

Let us move these pieces $M$ times as follows.

翻译中…
  • In the $i$-th move, given a positive integer $D_i$, we move each piece as follows.
  • A piece whose coordinate is a negative integer is moved a distance of $D_i$ in the positive direction.
    • A piece whose coordinate is $0$ is not moved.
    • A piece whose coordinate is a positive integer is moved a distance of $D_i$ in the negative direction.
翻译中…

Determine whether each piece arrives at the origin. If it does, print the number of moves after which it arrives there for the first time. Otherwise, print its coordinate after the $M$ moves.

翻译中…

Constraints

翻译中…
  • $1\leq N\leq 3\times 10^5$
  • $1\leq M\leq 3\times 10^5$
  • $1\leq X_1 < \cdots < X_N \leq 10^6$
  • $1\leq D_i \leq 10^6$
翻译中…

Input

翻译中…

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

翻译中…

N M
X_1 \ldots X_N
D_1 \ldots D_M

翻译中…

Output

翻译中…

Print $N$ lines. The $i$-th line should describe the $i$-th piece in the following format.

翻译中…

If the piece arrives at the origin, let $x$ be the number of moves after which it arrives there for the first time, and print the following:

翻译中…

Yes x

翻译中…

If the piece does not arrive at the origin, let $x$ be its coordinate after the $M$ moves, and print the following:

翻译中…

No x

翻译中…

样例

Input #1
6 4
2 4 6 8 10 12
8 2 5 7
Output #1
No -6
No -4
Yes 2
Yes 1
Yes 2
No 4
The coordinate of each piece changes as follows. - The $1$-st piece: $\phantom{0}2\quad \longmapsto \quad -6\quad \longmapsto \quad -4\quad \longmapsto \quad \phantom{-}1 \quad \longmapsto \quad -6$. - The $2$-nd piece: $\phantom{0}4 \quad \longmapsto \quad -4\quad \longmapsto \quad -2 \quad \longmapsto \quad \phantom{-}3 \quad \longmapsto \quad -4$. - The $3$-rd piece: $\phantom{0}6 \quad \longmapsto \quad -2\quad \longmapsto \quad \phantom{-}0 \quad \longmapsto \quad \phantom{-}0 \quad \longmapsto \quad \phantom{-}0$. - The $4$-th piece: $\phantom{0}8 \quad \longmapsto \quad \phantom{-}0\quad \longmapsto \quad \phantom{-}0 \quad \longmapsto \quad \phantom{-}0 \quad \longmapsto \quad \phantom{-}0$. - The $5$-th piece: $10 \quad \longmapsto \quad \phantom{-}2\quad \longmapsto \quad \phantom{-}0 \quad \longmapsto \quad \phantom{-}0 \quad \longmapsto \quad \phantom{-}0$. - The $6$-th piece: $12 \quad \longmapsto \quad \phantom{-}4\quad \longmapsto \quad \phantom{-}2 \quad \longmapsto \quad -3 \quad \longmapsto \quad \phantom{-}4$.
题目信息
题号
arc149_d
时间限制
2 s
内存限制
1024 MB

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