提交时间:2024-05-19 21:16:26

运行 ID: 147845

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