#P8847. [JRKSJ R5] 1-1 A
[JRKSJ R5] 1-1 A
Background
This problem is an easier version of 1-1. The harder version is 1-1 B.
Problem Description
You are given a sequence . For all , .
You may reorder the sequence arbitrarily. You need to minimize the maximum subarray sum of the sequence after reordering.
Input Format
The first line contains an integer .
The second line contains integers representing .
Output Format
Output one line with integers separated by spaces, representing the reordered sequence.
If there are multiple solutions, output any one of them.
4
1 1 -1 -1
1 -1 -1 1
Hint
Definition of the maximum subarray sum: the maximum value of the sum over any subarray of the sequence, i.e. .
This problem uses . As long as your output satisfies the requirements, it will be accepted.
The input and output files of this problem are large, so please use appropriate input and output methods.
Constraints
This problem uses bundled testdata.
For of the testdata, , and .
Translated by ChatGPT 5