提交时间:2024-05-19 20:58:44

运行 ID: 147844

# include <bits/stdc++.h> using namespace std ; int a [114514] , n , maxs ; void dfs ( int cur , int t1 , int t2 ) { if ( cur > n ) { maxs = max ( maxs , min ( t1 , t2 ) ) ; return ; } dfs ( cur + 1 , t1 + a [cur] , t2 ) ; dfs ( cur + 1 , t1 , t2 + a [cur] ) ; return ; } int main ( ) { cin >> n ; for ( int i = 1 ; i <= n ; i ++ ) { cin >> a [i] ; } dfs ( 1 , 0 , 0 ) ; cout << maxs << endl ; return 0 ; }