Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
文字列が N 個与えられます。
i 番目 (1\leq i\leq N) に与えられる文字列 S _ i は Takahashi か Aoki のどちらかと等しいです。
S _ i が Takahashi と等しい i がいくつあるか求めてください。
制約
- 1\leq N\leq 100
- N は整数
- S _ i は
TakahashiかAokiのいずれか (1\leq i\leq N)
入力
入力は以下の形式で標準入力から与えられる。
N S _ 1 S _ 2 \vdots S _ N
出力
S _ i が Takahashi と等しい i の個数を整数として一行に出力せよ。
入力例 1
3 Aoki Takahashi Takahashi
出力例 1
2
S _ 2,S _ 3 の 2 つが Takahashi と等しく、S _ 1 はそうではありません。
よって、2 を出力してください。
入力例 2
2 Aoki Aoki
出力例 2
0
Takahashi と等しい S _ i が存在しないこともあります。
入力例 3
20 Aoki Takahashi Takahashi Aoki Aoki Aoki Aoki Takahashi Aoki Aoki Aoki Takahashi Takahashi Aoki Takahashi Aoki Aoki Aoki Aoki Takahashi
出力例 3
7
Score : 100 points
Problem Statement
You are given N strings.
The i-th string S_i (1 \leq i \leq N) is either Takahashi or Aoki.
How many i are there such that S_i is equal to Takahashi?
Constraints
- 1 \leq N \leq 100
- N is an integer.
- Each S_i is
TakahashiorAoki. (1 \leq i \leq N)
Input
The input is given from Standard Input in the following format:
N S_1 S_2 \vdots S_N
Output
Print the count of i such that S_i is equal to Takahashi as an integer in a single line.
Sample Input 1
3 Aoki Takahashi Takahashi
Sample Output 1
2
S_2 and S_3 are equal to Takahashi, while S_1 is not.
Therefore, print 2.
Sample Input 2
2 Aoki Aoki
Sample Output 2
0
It is possible that no S_i is equal to Takahashi.
Sample Input 3
20 Aoki Takahashi Takahashi Aoki Aoki Aoki Aoki Takahashi Aoki Aoki Aoki Takahashi Takahashi Aoki Takahashi Aoki Aoki Aoki Aoki Takahashi
Sample Output 3
7
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
整数 a, b, c が与えられます。b がこれらの整数の中央値であるかどうか判定してください。
制約
- 1 \leq a, b, c \leq 100
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
a b c
出力
b が与えられた整数の中央値であるならば Yes、そうでないならば No と出力せよ。
入力例 1
5 3 2
出力例 1
Yes
与えられた整数を小さい順に並べると 2, 3, 5 となり、b はこれらの整数の中央値です。
入力例 2
2 5 3
出力例 2
No
b は与えられた整数の中央値ではありません。
入力例 3
100 100 100
出力例 3
Yes
Score : 100 points
Problem Statement
Given integers a, b, and c, determine if b is the median of these integers.
Constraints
- 1 \leq a, b, c \leq 100
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
a b c
Output
If b is the median of the given integers, then print Yes; otherwise, print No.
Sample Input 1
5 3 2
Sample Output 1
Yes
The given integers are 2, 3, 5 when sorted in ascending order, of which b is the median.
Sample Input 2
2 5 3
Sample Output 2
No
b is not the median of the given integers.
Sample Input 3
100 100 100
Sample Output 3
Yes
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
xy 平面を考えます。x 軸の正の向きを東向き、y 軸の正の向きを北向きとします。
高橋君ははじめ、点 (x, y) = (0, 0) にいて東( x 軸の正の向き)を向いています。
S と R のみからなる長さ N の文字列 T = t_1t_2\ldots t_N が与えられます。
高橋君は i = 1, 2, \ldots, N の順番で下記を行います。
- t_i =
Sならば、高橋君はいま向いている方向に距離 1 だけ進む。 - t_i =
Rならば、高橋君はその場で右に 90 度回転する。その結果、高橋君の向いている方向が下記の通りに変わる。- 回転前の向きが東向き( x 軸の正の向き)ならば、回転後の向きは南向き( y 軸の負の向き)になる。
- 回転前の向きが南向き( y 軸の負の向き)ならば、回転後の向きは西向き( x 軸の負の向き)になる。
- 回転前の向きが西向き( x 軸の負の向き)ならば、回転後の向きは北向き( y 軸の正の向き)になる。
- 回転前の向きが北向き( y 軸の正の向き)ならば、回転後の向きは東向き( x 軸の正の向き)になる。
上記の手順を終えた後に高橋君がいる点の座標を出力してください。
制約
- 1 \leq N \leq 10^5
- N は整数
- T は
SとRのみからなる長さ N の文字列
入力
入力は以下の形式で標準入力から与えられる。
N T
出力
問題文中の手順を終えた後に高橋君がいる点の座標 (x, y) を、下記の形式にしたがって空白区切りで出力せよ。
x y
入力例 1
4 SSRS
出力例 1
2 -1
高橋君ははじめ (0, 0) にいて東を向いています。その後、高橋君は下記の通りに行動します。
- t_1 =
Sであるので、高橋君は東に距離 1 だけ進んだ (1, 0) に移動します。 - t_2 =
Sであるので、高橋君は東に距離 1 だけ進んだ (2, 0) に移動します。 - t_3 =
Rであるので、高橋君は右に 90 度回転し、高橋君は南を向きます。 - t_4 =
Sであるので、高橋君は南に距離 1 だけ進んだ (2, -1) に移動します。
よって、高橋君の最終的な位置である (x, y) = (2, -1) を出力します。
入力例 2
20 SRSRSSRSSSRSRRRRRSRR
出力例 2
0 1
Score : 200 points
Problem Statement
Consider an xy-plane. The positive direction of the x-axis is in the direction of east, and the positive direction of the y-axis is in the direction of north.
Takahashi is initially at point (x, y) = (0, 0) and facing east (in the positive direction of the x-axis).
You are given a string T = t_1t_2\ldots t_N of length N consisting of S and R.
Takahashi will do the following move for each i = 1, 2, \ldots, N in this order.
- If t_i =
S, Takahashi advances in the current direction by distance 1. - If t_i =
R, Takahashi turns 90 degrees clockwise without changing his position. As a result, Takahashi's direction changes as follows.- If he is facing east (in the positive direction of the x-axis) before he turns, he will face south (in the negative direction of the y-axis) after he turns.
- If he is facing south (in the negative direction of the y-axis) before he turns, he will face west (in the negative direction of the x-axis) after he turns.
- If he is facing west (in the negative direction of the x-axis) before he turns, he will face north (in the positive direction of the y-axis) after he turns.
- If he is facing north (in the positive direction of the y-axis) before he turns, he will face east (in the positive direction of the x-axis) after he turns.
Print the coordinates Takahashi is at after all the steps above have been done.
Constraints
- 1 \leq N \leq 10^5
- N is an integer.
- T is a string of length N consisting of
SandR.
Input
Input is given from Standard Input in the following format:
N T
Output
Print the coordinates (x, y) Takahashi is at after all the steps described in the Problem Statement have been completed, in the following format, with a space in between:
x y
Sample Input 1
4 SSRS
Sample Output 1
2 -1
Takahashi is initially at (0, 0) facing east. Then, he moves as follows.
- t_1 =
S, so he advances in the direction of east by distance 1, arriving at (1, 0). - t_2 =
S, so he advances in the direction of east by distance 1, arriving at (2, 0). - t_3 =
R, so he turns 90 degrees clockwise, resulting in facing south. - t_4 =
S, so he advances in the direction of south by distance 1, arriving at (2, -1).
Thus, Takahashi's final position, (x, y) = (2, -1), should be printed.
Sample Input 2
20 SRSRSSRSSSRSRRRRRSRR
Sample Output 2
0 1
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
N 個の駅 1,2,\dots,N があり、これらはこの順に西から東に一直線上に並んでいます。
AtCoder 鉄道の電車はこれら N 個の駅を通り、西から東に走っています。
1 \leq i \lt j \leq N を満たす任意の 2 整数 i,j について、駅 i から電車に乗って駅 j で降りるのにコストが C_{i,j} かかります。
以下のような 3 つの整数 a,b,c が存在するかを判定してください。
- 1 \leq a \lt b \lt c \leq N
- 駅 a から電車に乗って駅 c で降りるときにかかるコストよりも、駅 a から電車に乗って駅 b で降り、再度、駅 b から電車に乗って駅 c で降りるときにかかるコストの総和の方が小さい。
制約
- 3 \leq N \leq 100
- 1 \leq C_{i,j} \leq 10^9
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N
C_{1,2} C_{1,3} \dots C_{1,N}
C_{2,3} \dots C_{2,N}
\vdots
C_{N-1,N}
出力
条件を満たす 3 整数 a,b,c が存在するならば Yes を、存在しないならば No を 1 行で出力せよ。
入力例 1
3 45 450 45
出力例 1
Yes
(a,b,c) として (1,2,3) を選ぶと、
C_{a,b}+C_{b,c}=C_{1,2}+C_{2,3}=45+45
C_{a,c}=C_{1,3}=450
なので、条件を満たします。
入力例 2
4 25 40 65 30 55 25
出力例 2
No
どのように (a,b,c) を選んでも、条件を満たしません。
Score : 200 points
Problem Statement
There are N stations 1, 2, \dots, N, arranged in a straight line from west to east in this order.
The AtCoder Railway train passes through these N stations and runs from west to east.
For any two integers i, j satisfying 1 \leq i \lt j \leq N, the cost of boarding the train at station i and getting off at station j is C_{i,j}.
Determine whether there exist three integers a, b, c such that:
- 1 \leq a \lt b \lt c \leq N
- The total cost of boarding the train at station a, getting off at station b, then boarding the train again at station b, and getting off at station c is less than the cost of boarding the train at station a and getting off at station c.
Constraints
- 3 \leq N \leq 100
- 1 \leq C_{i,j} \leq 10^9
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N
C_{1,2} C_{1,3} \dots C_{1,N}
C_{2,3} \dots C_{2,N}
\vdots
C_{N-1,N}
Output
If there exist three integers a, b, c satisfying the conditions, output Yes; otherwise, output No, on a single line.
Sample Input 1
3 45 450 45
Sample Output 1
Yes
Choosing (a, b, c) = (1, 2, 3),
C_{a,b}+C_{b,c}=C_{1,2}+C_{2,3}=45+45
C_{a,c}=C_{1,3}=450
so the conditions are satisfied.
Sample Input 2
4 25 40 65 30 55 25
Sample Output 2
No
No choice of (a, b, c) satisfies the conditions.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
高橋君はレベル N の赤い宝石を 1 個持っています。(他に宝石は持っていません。)
高橋君は次の操作を好きなだけ行うことができます。
- レベル n の赤い宝石 (n は 2 以上) を「レベル n-1 の赤い宝石 1 個と、レベル n の青い宝石 X 個」に変換する。
- レベル n の青い宝石 (n は 2 以上) を「レベル n-1 の赤い宝石 1 個と、レベル n-1 の青い宝石 Y 個」に変換する。
高橋君はレベル 1 の青い宝石ができるだけたくさんほしいです。操作によって高橋君はレベル 1 の青い宝石を最大何個入手できますか?
制約
- 1 \leq N \leq 10
- 1 \leq X \leq 5
- 1 \leq Y \leq 5
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N X Y
出力
答えを出力せよ。
入力例 1
2 3 4
出力例 1
12
次のような変換を行うことで、高橋君はレベル 1 の青い宝石を 12 個手に入れることができます。
- まず、レベル 2 の赤い宝石 1 個を、レベル 1 の赤い宝石 1 個とレベル 2 の青い宝石 3 個に変換します。
- 操作後の高橋君は、レベル 1 の赤い宝石 1 個とレベル 2 の青い宝石 3 個を持っています。
- 次に、レベル 2 の青い宝石 1 個を、レベル 1 の赤い宝石 1 個とレベル 1 の青い宝石 4 個に変換します。この変換を 3 回繰り返します。
- 操作後の高橋君は、レベル 1 の赤い宝石 4 個とレベル 1 の青い宝石 12 個を持っています。
- これ以上変換を行うことはできません。
12 個より多くレベル 1 の青い宝石を手に入れることはできないので、答えは 12 になります。
入力例 2
1 5 5
出力例 2
0
高橋君がレベル 1 の青い宝石を 1 個も手に入れられない場合もあります。
入力例 3
10 5 5
出力例 3
3942349900
答えが 32 bit 整数に収まらない場合があることに注意してください。
Score : 300 points
Problem Statement
Takahashi has a red jewel of level N. (He has no other jewels.)
Takahashi can do the following operations any number of times.
- Convert a red jewel of level n (n is at least 2) into "a red jewel of level (n-1) and X blue jewels of level n".
- Convert a blue jewel of level n (n is at least 2) into "a red jewel of level (n-1) and Y blue jewels of level (n-1)".
Takahashi wants as many blue jewels of level 1 as possible. At most, how many blue jewels of level 1 can he obtain by the operations?
Constraints
- 1 \leq N \leq 10
- 1 \leq X \leq 5
- 1 \leq Y \leq 5
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X Y
Output
Print the answer.
Sample Input 1
2 3 4
Sample Output 1
12
Takahashi can obtain 12 blue jewels of level 1 by the following conversions.
- First, he converts a red jewel of level 2 into a red jewel of level 1 and 3 blue jewels of level 2.
- After this operation, Takahashi has 1 red jewel of level 1 and 3 blue jewels of level 2.
- Next, he repeats the following conversion 3 times: converting a blue jewel of level 2 into a red jewel of level 1 and 4 blue jewels of level 1.
- After these operations, Takahashi has 4 red jewels of level 1 and 12 blue jewels of level 1.
- He cannot perform a conversion anymore.
He cannot obtain more than 12 blue jewels of level 1, so the answer is 12.
Sample Input 2
1 5 5
Sample Output 2
0
Takahashi may not be able to obtain a blue jewel of level 1.
Sample Input 3
10 5 5
Sample Output 3
3942349900
Note that the answer may not fit into a 32-bit integer type.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
1 から N の番号がついた N 人の人がいます。人 i は数 A_i を持っています。
「自分と同じ数を持っている人が自分以外の N-1 人の中に存在しない」という条件を満たす人のうち、持っている数が最大である人の番号を求めてください。
条件を満たす人が存在しない場合、代わりにそのことを報告してください。
制約
- 1 \leq N \leq 3\times 10^5
- 1 \leq A_i \leq 10^9
- 入力は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \ldots A_N
出力
「自分と同じ数を持っている人が自分以外の N-1 人の中に存在しない」という条件を満たす人が存在しない場合、-1 と出力せよ。
条件を満たす人が存在する場合、そのうち、持っている数が最大である人の番号を出力せよ。
入力例 1
9 2 9 9 7 9 2 4 5 8
出力例 1
9
「自分と同じ数を持っている人が自分以外の N-1 人の中に存在しない」という条件を満たすのは人 4,7,8,9 の 4 人です。
これらの人が持っている数はそれぞれ 7,4,5,8 であり、最大の数を持っているのは人 9 です。
よって答えは 9 となります。
入力例 2
4 1000000000 1000000000 998244353 998244353
出力例 2
-1
条件を満たす人が存在しない場合、-1 を出力してください。
Score : 300 points
Problem Statement
There are N people, labeled 1 to N. Person i has an integer A_i.
Among the people who satisfy the condition "None of the other N-1 people has the same integer as themselves," find the one with the greatest integer, and print that person's label.
If no person satisfies the condition, report that fact instead.
Constraints
- 1 \leq N \leq 3\times 10^5
- 1 \leq A_i \leq 10^9
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 A_2 \ldots A_N
Output
If no person satisfies the condition "None of the other N-1 people has the same integer as themselves," print -1.
Otherwise, among those who satisfy it, print the label of the person whose integer is the largest.
Sample Input 1
9 2 9 9 7 9 2 4 5 8
Sample Output 1
9
Those who satisfy the condition are the persons labeled 4, 7, 8, and 9.
Their integers are 7, 4, 5, and 8, respectively, and the person with the largest integer is the person labeled 9.
Thus, the answer is 9.
Sample Input 2
4 1000000000 1000000000 998244353 998244353
Sample Output 2
-1
If no person satisfies the condition, print -1.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 400 点
問題文
長さ N の整数列 A = (A_1, \dots, A_N) が与えられます。
以下の条件を全て満たす整数の組 (i, j, k) の総数を求めてください。
- 1 \leq i, j, k \leq N
- \frac{A_i}{A_j} = A_k
制約
- 1 \leq N \leq 2 \times 10^5
- 1 \leq A_i \leq 2 \times 10^5 \, (1 \leq i \leq N)
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 \ldots A_N
出力
答えを出力せよ。
入力例 1
3 6 2 3
出力例 1
2
(i, j, k) = (1, 2, 3), (1, 3, 2) が条件を満たします。
入力例 2
1 2
出力例 2
0
入力例 3
10 1 3 2 4 6 8 2 2 3 7
出力例 3
62
Score : 400 points
Problem Statement
You are given an integer sequence A = (A_1, \dots, A_N) of length N.
Find the number of triplets of integers (i, j, k) satisfying all of the conditions below.
- 1 \leq i, j, k \leq N
- \frac{A_i}{A_j} = A_k
Constraints
- 1 \leq N \leq 2 \times 10^5
- 1 \leq A_i \leq 2 \times 10^5 \, (1 \leq i \leq N)
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N A_1 \ldots A_N
Output
Print the answer.
Sample Input 1
3 6 2 3
Sample Output 1
2
(i, j, k) = (1, 2, 3), (1, 3, 2) satisfy the conditions.
Sample Input 2
1 2
Sample Output 2
0
Sample Input 3
10 1 3 2 4 6 8 2 2 3 7
Sample Output 3
62
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 450 点
問題文
長さ 3^n \; (n \geq 1) の 01 列 B=B_1 B_2 \dots B_{3^n} に対して、長さ 3^{n-1} の 01 列 C=C_1 C_2 \dots C_{3^{n-1}} を得る操作を以下のように定めます。
- B の要素を 3 つずつまとめて多数決を取る。すなわち、i=1,2,\dots,3^{n-1} について、B_{3i-2},B_{3i-1},B_{3i} のうち最も多く現れる値を C_i とする。
長さ 3^N の 01 列 A = A_1 A_2 \dots A_{3^N} が与えられます。A に上の操作を N 回適用して得られる長さ 1 の列を A' = A'_1 とします。
A の要素のいくつかを 0 から 1 または 1 から 0 へ変えることを考えたとき、A の要素を最小で何個変えれば、A'_1 の値が変わるか求めてください。
制約
- N は 1 以上 13 以下の整数
- A は 0,1 からなる長さ 3^N の文字列
入力
入力は以下の形式で標準入力から与えられる。
N
A_1 A_2 \dots A_{3^N}
出力
答えを出力せよ。
入力例 1
2 010011101
出力例 1
1
A=010011101 に操作を 2 回適用すると、以下のようになります。
- 1 回目: 010 の過半数は 0, 011 の過半数は 1, 101 の過半数は 1 なので、これらをつなげて 011 を得る。
- 2 回目: 011 の過半数は 1 なので、 1 を得る。
最終的な値を 1 から 0 にするためには、例えば A の 5 文字目を 1 から 0 にして A=010001101 にすればよいです。変更後、操作は以下のようになります。
- 1 回目: 010 の過半数は 0, 001 の過半数は 0, 101 の過半数は 1 なので、これらをつなげて 001 を得る。
- 2 回目: 001 の過半数は 0 なので、 0 を得る。
よって、 A の要素を 1 個変えるのが最小です。
入力例 2
1 000
出力例 2
2
Score : 450 points
Problem Statement
For a binary string B = B_1 B_2 \dots B_{3^n} of length 3^n (n \geq 1), we define an operation to obtain a binary string C = C_1 C_2 \dots C_{3^{n-1}} of length 3^{n-1} as follows:
- Partition the elements of B into groups of 3 and take the majority value from each group. That is, for i=1,2,\dots,3^{n-1}, let C_i be the value that appears most frequently among B_{3i-2}, B_{3i-1}, and B_{3i}.
You are given a binary string A = A_1 A_2 \dots A_{3^N} of length 3^N. Let A' = A'_1 be the length-1 string obtained by applying the above operation N times to A.
Determine the minimum number of elements of A that must be changed (from 0 to 1 or from 1 to 0) in order to change the value of A'_1.
Constraints
- N is an integer with 1 \leq N \leq 13.
- A is a string of length 3^N consisting of 0 and 1.
Input
The input is given from Standard Input in the following format:
N
A_1 A_2 \dots A_{3^N}
Output
Print the answer.
Sample Input 1
2 010011101
Sample Output 1
1
For example, with A=010011101, after applying the operation twice, we obtain:
- First operation: The majority of 010 is 0, of 011 is 1, and of 101 is 1, resulting in 011.
- Second operation: The majority of 011 is 1, yielding 1.
To change the final value from 1 to 0, one way is to change the 5th character of A from 1 to 0, yielding A=010001101. After the change, the operations yield:
- First operation: The majority of 010 is 0, of 001 is 0, and of 101 is 1, resulting in 001.
- Second operation: The majority of 001 is 0, yielding 0.
Thus, the minimum number of changes required is 1.
Sample Input 2
1 000
Sample Output 2
2
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 500 点
問題文
正整数列 A=(a_1,a_2,\ldots,a_N) が与えられます。
あなたは次の操作を 0 回以上何度でも繰り返せます。
- A から(空でない)連続する部分列を選び、削除する。
x=1,2,\ldots,M に対し、次の問題を解いてください。
- A の要素の総和をちょうど x にするために必要な操作回数の最小値を求めてください。ただし、どのように操作を行っても A の要素の総和をちょうど x にできない場合は代わりに
-1と出力してください。
なお、A が空である時、A の要素の総和は 0 であるとします。
制約
- 1 \leq N,M \leq 3000
- 1 \leq a_i \leq 3000
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N M a_1 \ldots a_N
出力
M 行出力せよ。i 行目には x=i に対する答えを出力せよ。
入力例 1
4 5 1 2 3 4
出力例 1
1 2 1 1 1
操作回数が最小である操作の例を以下に示します。
- x=1 について、a_2,a_3,a_4 に対して操作をすることで A の要素の総和が x になります。
- x=2 について、a_3,a_4 に対して操作をした後、a_1 に対して操作をすることで A の要素の総和が x になります。
- x=3 について、a_3,a_4 に対して操作をすることで A の要素の総和が x になります。
- x=4 について、a_1,a_2,a_3 に対して操作をすることで A の要素の総和が x になります。
- x=5 について、a_2,a_3 に対して操作をすることで A の要素の総和が x になります。
入力例 2
1 5 3
出力例 2
-1 -1 0 -1 -1
入力例 3
12 20 2 5 6 5 2 1 7 9 7 2 5 5
出力例 3
2 1 2 2 1 2 1 2 2 1 2 1 1 1 2 2 1 1 1 1
Score : 500 points
Problem Statement
You are given an integer array A=(a_1,a_2,\ldots,a_N).
You may perform the following operation any number of times (possibly zero).
- Choose a nonempty contiguous subarray of A, and delete it from the array.
For each x=1,2,\ldots,M, solve the following problem:
- Find the minimum possible number of operations to make the sum of elements of A equal x.
If it is impossible to make the sum of elements of A equal x, print
-1instead.
Note that the sum of elements of an empty array is 0.
Constraints
- 1 \leq N,M \leq 3000
- 1 \leq a_i \leq 3000
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
N M a_1 \ldots a_N
Output
Print M lines. The i-th line should contain the answer for x=i.
Sample Input 1
4 5 1 2 3 4
Sample Output 1
1 2 1 1 1
The followings are examples of minimum number of operations that achieve the goal.
- For x=1, delete a_2,a_3,a_4, and the sum of elements of A becomes x.
- For x=2, delete a_3,a_4, then delete a_1, and the sum of elements of A becomes x.
- For x=3, delete a_3,a_4, and the sum of elements of A becomes x.
- For x=4, delete a_1,a_2,a_3, and the sum of elements of A becomes x.
- For x=5, delete a_2,a_3, and the sum of elements of A becomes x.
Sample Input 2
1 5 3
Sample Output 2
-1 -1 0 -1 -1
Sample Input 3
12 20 2 5 6 5 2 1 7 9 7 2 5 5
Sample Output 3
2 1 2 2 1 2 1 2 2 1 2 1 1 1 2 2 1 1 1 1