A - chmin
Editorial
/
/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
長さ N の整数列 A=(A_1,A_2,\dots,A_N) と整数 X が与えられます。
i=1,2,\dots,N の順に以下を行ってください。
- もし A_i<X なら、 X=A_i に更新した上で
1を出力する。 - そうでないなら
0を出力する。
制約
- 入力は全て整数
- 1 \le N,X,A_i \le 100
入力
入力は以下の形式で標準入力から与えられる。
N X A_1 A_2 \dots A_N
出力
N 行出力せよ。
そのうち k 行目には、 i=k についての出力をせよ。
入力例 1
5 10 6 4 7 1 3
出力例 1
1 1 0 1 0
- 最初、 X=10 です。
- i=1 について、 A_1=6<X=10 なので、 X=6 に更新した上で
1を出力します。 - i=2 について、 A_2=4<X=6 なので、 X=4 に更新した上で
1を出力します。 - i=3 について、 A_3=7 \ge X=4 なので、
0を出力します。 - i=4 について、 A_4=1<X=4 なので、 X=1 に更新した上で
1を出力します。 - i=5 について、 A_5=3 \ge X=1 なので、
0を出力します。
入力例 2
1 1 1
出力例 2
0
入力例 3
8 20 9 19 14 17 17 4 18 4
出力例 3
1 0 0 0 0 1 0 0
Score : 100 points
Problem Statement
You are given a length-N integer sequence A=(A_1,A_2,\dots,A_N) and an integer X.
For i=1,2,\dots,N in this order, do the following.
- If A_i<X, update X=A_i and output
1. - Otherwise, output
0.
Constraints
- All input values are integers.
- 1 \le N,X,A_i \le 100
Input
The input is given from Standard Input in the following format:
N X A_1 A_2 \dots A_N
Output
Output N lines.
The k-th line should contain the output for i=k.
Sample Input 1
5 10 6 4 7 1 3
Sample Output 1
1 1 0 1 0
- Initially, X=10.
- For i=1: since A_1=6<X=10, update X=6 and output
1. - For i=2: since A_2=4<X=6, update X=4 and output
1. - For i=3: since A_3=7 \ge X=4, output
0. - For i=4: since A_4=1<X=4, update X=1 and output
1. - For i=5: since A_5=3 \ge X=1, output
0.
Sample Input 2
1 1 1
Sample Output 2
0
Sample Input 3
8 20 9 19 14 17 17 4 18 4
Sample Output 3
1 0 0 0 0 1 0 0