No.1722 [Cherry 3rd Tune C] In my way
問題文最終更新日: 2021-11-06 00:15:09
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 320 (Stray Bullet)
(順位表)
の他の問題:
Problem Statement
There are $N$ people and $M$ obstacles on a number line. The $i$-th person is standing at coordinate $X_i$, and the $j$-th obstacle is at coordinate $Y_j$.
Here, it is guaranteed that $X_1, \dots, X_N, Y_1, \dots, Y_M$ are all distinct.
Each of the $N$ people walks in the positive direction at speed $1$, but when a person's coordinate reaches a coordinate where an obstacle exists, that person stops walking there.
Find the distance walked by each of the $N$ people.
Constraints
- $1 \leq N,M \leq 1000$
- $0 \leq X_i, Y_j \leq 10^9$
- $X_1, \dots, X_N, Y_1, \dots, Y_M$ are all distinct.
- All inputs are integers.
Input
The input is given from standard input in the following format.$N$ $M$ $X_1$ $\cdots$ $X_N$ $Y_1$ $\cdots$ $Y_M$
Output
The output consists of $N$ lines. On the $i$-th line, print the distance the $i$-th person will walk. However, if the $i$-th person would keep walking forever, print Infinity.
Sample
Sample 1
Input
5 4 0 10 20 5 15 3 12 17 13
Output
3 2 Infinity 7 2
- Person $1$ starts walking from coordinate $0$ in the positive direction at speed $1$. Then, they reach the obstacle at coordinate $3$ and stop walking there. Thus, person $1$ walked a distance of $3$.
- Person $2$ starts walking from coordinate $10$ in the positive direction at speed $1$. Then, they reach the obstacle at coordinate $12$ and stop walking there. Thus, person $3$ walked a distance of $2$.
- Person $3$ starts walking from coordinate $20$ in the positive direction at speed $1$. They never reach an obstacle and keep walking forever.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
Kazun
tatyam
magsta