inline T read(){ T sum = 0, fl = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1; for (; isdigit(ch); ch = getchar()) sum = sum * 10 + ch - '0'; return sum * fl; }
template <typename T>
inlinevoidwrite(T x){ if (x < 0) { putchar('-'), write<T>(-x); return; } static T sta[35]; int top = 0; do { sta[top++] = x % 10, x /= 10; } while (x); while (top) putchar(sta[--top] + 48); }
voiddfs(int group, int cnt){ if (group == n) { ans = min(ans, max(cnt, sum - cnt)); return; } // 组 A dfs(group + 1, cnt + a[group]); // 组 B dfs(group + 1, cnt); }
intmain(){ n = read<int>(); FOR(i, 1, n) a[i] = read<int>(), sum += a[i]; dfs(1, 0); write<int>(ans); return0; } // 20组---》爆搜挂着机,打表出 AC