AtCoder Grand Contest 020
C
Median Sum
AtCoder
⌀ 2259
原题
← BD →
翻译中…

Problem Statement

翻译中…

You are given $N$ integers $A_1$, $A_2$, ..., $A_N$.

翻译中…

Consider the sums of all non-empty subsequences of $A$. There are $2^N - 1$ such sums, an odd number.

翻译中…

Let the list of these sums in non-decreasing order be $S_1$, $S_2$, ..., $S_{2^N - 1}$.

翻译中…

Find the median of this list, $S_{2^{N-1}}$.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 2000$
  • $1 \leq A_i \leq 2000$
  • All input values are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 ... A_N

翻译中…

Output

翻译中…

Print the median of the sorted list of the sums of all non-empty subsequences of $A$.

翻译中…

样例

Input #1
3
1 2 1
Output #1
2
In this case, $S = (1, 1, 2, 2, 3, 3, 4)$. Its median is $S_4 = 2$.
Input #2
1
58
Output #2
58
In this case, $S = (58)$.
题目信息
题号
agc020_c
时间限制
2 s
内存限制
512 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。