#K62932. Maximizing the K-th Smallest Subarray Sum
Maximizing the K-th Smallest Subarray Sum
Maximizing the K-th Smallest Subarray Sum
Given two integers \( n \) and \( k \), your task is to construct a binary array \( a \) of length \( n \) (i.e. each element is either 0 or 1) such that the \( k \)-th smallest sum among all continuous subarrays of \( a \) is maximized.
A continuous subarray is a sequence of consecutive elements in \( a \). Let \( S \) be the multiset of sums of all continuous subarrays. Denote the \( k \)-th smallest element in \( S \) as \( f(k) \). Your goal is to design an array \( a \) so that \( f(k) \) is as large as possible.
Note: Although the optimal construction can be very challenging, you may use a heuristic approach that guarantees a binary array with a reasonable \( f(k) \) value. For example, setting ones in alternating positions might produce relatively high subarray sums.
For example:
Input: 5 3 Output: 1 0 1 1 0</p>Input: 1 1 Output: 1
inputFormat
The input is read from standard input and consists of a single line containing two space-separated integers:
- \( n \) (the length of the binary array), and
- \( k \) (the rank of the continuous subarray sum to maximize).
\( 1 \leq n \leq 10^5 \) and \( 1 \leq k \leq \frac{n(n+1)}{2} \).
outputFormat
Print the binary array as \( n \) space-separated integers (each integer is either 0 or 1) to standard output.
## sample5 3
1 0 1 1 0