QOJ.ac

QOJ

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

#978. Subsecuencia máxima

Statistics

Para una secuencia $a_{1 \dots n}$, definimos $f(a)$ como:

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

Dada una secuencia $b_{1 \dots n}$, usted debe permutar $b_{1 \dots n}$ para obtener $b'_{1 \dots n}$ y minimizar $f(b')$.

Entrada

La primera línea contiene un único entero $n$ ($1 \le n \le 16$).

La segunda línea contiene $n$ enteros $a_{1 \dots n}$ ($|a_i| \le 10^5$).

Salida

Imprima el valor mínimo posible de $f(b')$.

Ejemplos

Entrada 1

4
1 -1 1 1

Salida 1

2

Entrada 2

6
4 -4 5 -20 6 7

Salida 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.