C - Subarray Sum Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 400400

問題文

33 つの整数 NN, KK, SS が与えられます。

11 以上 10910^9 以下の整数からなる長さ NN の数列 A1,A2,...,ANA_1, A_2, ..., A_N であって、 以下の条件を満たすものをひとつ求めてください。 なお、制約の項で記述される条件のもとで、このような数列は必ず存在することが証明できます。

  • 1lrN1 \leq l \leq r \leq N を満たす整数の組 (l,r)(l, r) であって、 Al+Al+1++Ar=SA_l + A_{l + 1} + \cdots + A_r = S を満たすものはちょうど KK 個ある。

制約

  • 1N1051 \leq N \leq 10^5
  • 0KN0 \leq K \leq N
  • 1S1091 \leq S \leq 10^9
  • 入力値はすべて整数である。

入力

入力は以下の形式で標準入力から与えられる。

NN KK SS

出力

条件を満たす数列を以下の形式で出力せよ。

A1A_1 A2A_2 ...... ANA_N

入力例 1Copy

Copy
4 2 3

出力例 1Copy

Copy
1 2 3 4

問題文の条件を満たす (l,r)(l, r)(1,2)(1, 2)(3,3)(3, 3)22 個あります。


入力例 2Copy

Copy
5 3 100

出力例 2Copy

Copy
50 50 50 30 70

Score : 400400 points

Problem Statement

Given are three integers NN, KK, and SS.

Find a sequence A1,A2,...,ANA_1, A_2, ..., A_N of NN integers between 11 and 10910^9 (inclusive) that satisfies the condition below. We can prove that, under the conditions in Constraints, such a sequence always exists.

  • There are exactly KK pairs (l,r)(l, r) of integers such that 1lrN1 \leq l \leq r \leq N and Al+Al+1++Ar=SA_l + A_{l + 1} + \cdots + A_r = S.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 0KN0 \leq K \leq N
  • 1S1091 \leq S \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK SS

Output

Print a sequence satisfying the condition, in the following format:

A1A_1 A2A_2 ...... ANA_N

Sample Input 1Copy

Copy
4 2 3

Sample Output 1Copy

Copy
1 2 3 4

Two pairs (l,r)=(1,2)(l, r) = (1, 2) and (3,3)(3, 3) satisfy the condition in the statement.


Sample Input 2Copy

Copy
5 3 100

Sample Output 2Copy

Copy
50 50 50 30 70


2025-04-22 (Tue)
18:06:59 +00:00