QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB Total points: 100

#978. 最大部分列

Statistics

数列 $a_{1 \dots n}$ に対して、$f(a)$ を次のように定義します。

$$f(a) = \max_{1 \le l \le r \le n} \sum_{i=l}^{r} a_i$$

数列 $b_{1 \dots n}$ が与えられます。$b_{1 \dots n}$ を並べ替えて $b'_{1 \dots n}$ を作り、$f(b')$ を最小化してください。

入力

1行目に整数 $n$ ($1 \le n \le 16$) が与えられます。 2行目に $n$ 個の整数 $a_{1 \dots n}$ ($|a_i| \le 10^5$) が与えられます。

出力

$f(b')$ の最小値を出力してください。

入出力例

入力 1

4
1 -1 1 1

出力 1

2

入力 2

6
4 -4 5 -20 6 7

出力 2

9

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.